??? 11/26/09 07:58 Read: times |
#171184 - Thanks Kiran Responding to: ???'s previous message |
I have got it right. on the PC side i am using Com-debug on the computer side.
You are right. I did not think about it. what will happen if the result is more than 1 byte. i will take care of it. Generally what i want to do is use this string of characters as a command from 1 controller to the other. so i really do not need to total it. Totaling was just a test. I just moved the RI = 0; to the end of the routine and it worked here's the working code #include<reg51.h> #include<serial.h>//sets the baud rate and initilizes the controller serial port. #include<generic.h>//this has the delays, although this has no use in this program char recieved_0= 0x00; char recieved_1= 0x00; char recieved_2= 0x00; char recieved_3= 0x00; char recieved_4= 0x00; char rr = 0x00; int in = 0 ; void serial_interrupt() interrupt 4 { if(TI) { rr = 0x00;//resetting the summing variable TI = 0; } if(RI) { if(recieved_0 == 0) recieved_0 = SBUF;//first character else if(recieved_1 == 0) recieved_1 = SBUF;//second character else if(recieved_2 == 0) recieved_2 = SBUF;//third character else if(recieved_3 == 0) recieved_3 = SBUF;//fourth character else if(recieved_4 == 0) recieved_4 = SBUF;//fifth character RI = 0;//i just moved this here !!!! and it is working } } void main() { initialize_serial(); SBUF = 0xAA; usec_wait(20); while(1) { if(recieved_4 != 0)//this conditio will be true if the fourth character has some vlue in it { rr = recieved_0+recieved_1+recieved_2+recieved_3+recieved_4; recieved_0= 0x00;//reseting this varable bac to zero recieved_1= 0x00;//reseting this varable bac to zero recieved_2= 0x00;//reseting this varable bac to zero recieved_3= 0x00;//reseting this varable bac to zero recieved_4= 0x00;//reseting this varable bac to zero SBUF = rr;//sending out the result } } } |
Topic | Author | Date |
String of characters serially | 01/01/70 00:00 | |
Some more info needed and some tips | 01/01/70 00:00 | |
Thanks Kiran | 01/01/70 00:00 | |
Framing + counting | 01/01/70 00:00 |