5 unsigned char getchu(void) 6 { 8 while(!RCIF){}; 9 retur : Notes">

NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Experiment 9

Serial Asynchronous Communications


part1:Loop Back Test - UART

-----
ISIS:
pin25:to V.terminal(Rxd)
pin26:to V.termianl(Txd)
-------
code:
#include "ee470.h"
4 #include <ctype.h>
5 unsigned char getchu(void)
6 {
8 while(!RCIF){};
9 return(RCREG);
10 }
12 void putchu(unsigned char c)
13 {
15 while (!TXIF) {};
16 TXREG=c;
17 }
19 void main(void)
20 {
21 unsigned char c, d;
22 OSCCON=0x70;
23 ADCON1=0xF;
24 serial_init(51,1);
25 while(1) {
26 c = getchu();
27 d = toupper(c);
28 putchu(d);
29 }
30 }
############
part2:Get One Character from PC
and Echo it Back - UART

*Using the UART and the functions
available in ee445.h (getch and putch)
when you press 1---(1*)


--------
ISIS:
RA0:res=330 to led to gnd
pin25:to V.terminal(Rxd)
pin26:to V.termianl(Txd)
-------
code:
#include "ee470.h"
#include <string.h>
6 void main(void)
7 {
8 unsigned char c, k, line[40];
9 OSCCON=0x70;
10 ADCON1=0xF;
11 serial_init(51,1);
12 TRISA0=0;
13 PORTAbits.RA0=0;
14 TRISC1=1;
15 TRISC0=0;
16 PORTCbits.RC0=1;
17 strcpy(line,"Press 1 to get * followed by 1 and turn the LED ON xA xD");
18 for(k=0; k<strlen(line); k++) putch(line[k]);
19 while(1) {
20 c = getch();
21 if (c=='1')
22 {
23 PORTAbits.RA0=1;
24 putch('*');
25 }
26 else
27 RA0=0;
28 putch(c);
29 }
30 }
##############
part3:Two PICs connected Serially - UART

-----
ISIS:
system1:25 here to 26 in sys2
and 26 here to 25 in syst2
RA0 : res=330 to led to gnd
RA1 : res=330 to led to gnd
pin33:logicprobe
pin34:logicprobe

system2:25 here to 26 in sys1
and 26 here to 25 in syst1
RA0 : res=330 to led to gnd
RA1 : res=330 to led to gnd
pin33:logicprobe
pin34:logicprobe
-----
code:
there is 2codes here
code system1:
#include "ee470.h"
5 void main(void)
6 {
7 unsigned char x, c;
8 OSCCON=0x70;
9 ADCON1=0xF;
10 serial_init(51,1);
11 TRISB1=1; TRISB0=1;
12 TRISA1=0; TRISA0=0;
while(1)
15 {
17 if (bittst(PORTB,0)==0) bitclr(x,0); else bitset(x,0);
18 if (bittst(PORTB,1)==0) bitclr(x,1); else bitset(x,1);
19 putch(x);
20 c=getch();
21 // PORTA=c;
22 if (bittst(c,0)==0) bitclr(PORTA,0); else bitset(PORTA,0);
23 if (bittst(c,1)==0) bitclr(PORTA,1); else bitset(PORTA,1);
24 }
25 }


######
code system 2:
#include "ee470.h"
void main(void)
{
unsigned char x, c;
OSCCON=0x70;
ADCON1=0xF;
serial_init(51,1);
TRISB1=1; TRISB0=1;
TRISA1=0; TRISA0=0;
while(1)
{
c=getch();
if (bittst(c,0)==0) bitclr(PORTA,0); else bitset(PORTA,0);
if (bittst(c,1)==0) bitclr(PORTA,1); else bitset(PORTA,1);
if (bittst(PORTB,0)==0) bitclr(x,0); else bitset(x,0);
if (bittst(PORTB,1)==0) bitclr(x,1); else bitset(x,1);
putch(x);
}
}
####################
part4:Software to Serialize Data
and connect the PIC to PC without
UART - Software

*Without using UART, re-write
the echo program to make the
PIC communicates with the terminal
on the two wires RC0 (as Tx) and
RC1 (as Rx) at 9600bps, 1-stop, no parity.

------
ISIS:
RA0:res=330 to led to gnd
pin 15 : to V.terminal(Rxd)
pin 16: to V.termianl(Txd)
------
code:
include "ee470.h"
#include <string.h>
#define half_bit_delay __delay_us(42)
#define bit_delay __delay_us(84)
void putch_RC0(unsigned char ch)
{
int i;
PORTCbits.RC0=0;
bit_delay;
for(i=0; i<8; i++)
{
if(bittst(ch,i) == 0) PORTCbits.RC0=0; else PORTCbits.RC0=1;
bit_delay;
}
PORTCbits.RC0=1;
bit_delay;
}
unsigned char getch_RC1(void)
{
int i;
unsigned char ch;
while(PORTCbits.RC1==1);
half_bit_delay;
ch=0;
for(i=0; i<8; i++)
{
bit_delay;
if (PORTCbits.RC1==0) bitclr(ch,i); else bitset(ch,i);
}
bit_delay;
return ch;
}
void main(void)
{
unsigned char c, k, line[40];
OSCCON=0x70;
ADCON1=0xF;
TRISA0=0;
PORTAbits.RA0=0;
TRISC1=1;
TRISC0=0;
PORTCbits.RC0=1;
strcpy(line,"Press 1 to get * followed by 1 and turn the LED ON xAxD");
for(k=0; k<strlen(line); k++) putch_RC0(line[k]);
while(1) {
c = getch_RC1();
if (c=='1')
{
PORTAbits.RA0=1;
putch_RC0('*');
}
else
RA0=0;
putch_RC0(c);
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.