We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
if i send one character from 8051 board to hyperterminal its working. suppose if i send an array to hyperterminal its not working. can anybody suggest whats wrong with my code. here is my sample code #include<reg52.h> void main() { char name; unsigned int i; char hmi[] = {'0','0','0','0','3','0','3','3'}; PCON |= 0x80; TMOD = 0x20; TH1 = 0xFD; SCON = 0x50; TR1 = 1; while(1) { while(!RI); RI = 0; name = SBUF; TI = 0; SBUF = '#'; while(!TI); for(i = 0; i < 8; i++) { TI = 0; SBUF = hmi[i]; while(!TI); } i = 0; TI = 0; SBUF = '?'; while(!TI); } } }
Other than the fact that you posted code without having followed the instructions to use 'pre' tags to preserve code formatting and that there's an extra closing brace, there is nothing particularly wrong with your code. If you could send a single byte, you should be able to send multiple bytes. Since you are sending bytes back-to-back, how about checking HyperTerminal's setting for stop bits. It has to be set to '1' or you'll have to add a bit-time delay between sending bytes.
"... HyperTerminal's setting for stop bits. It has to be set to '1' ..." Never mind. I was being a doofus.
yes hyperterminal setting is 1. but still there is a problem in transmitting array. even i included a small delay between values. but its not working
while transmitting array, controller is sending some garbage values. but if i send one value, controller is transmitting correctly
while transmitiing as an array, does the first data getting transmitted correctly or all the data are transmittingas garbage?
while(!RI); RI = 0; name = SBUF; TI = 0; SBUF = '#'; while(!TI); for(i = 0; i < 8; i++) { TI = 0; SBUF = hmi[i]; while(!TI); } i = 0; Just a glance at the above makes it obvious the you do oodles and bunches of stuff before detecting RI the second rime. Then, of course you will react to an "old" RI, seven more may have occured whay do I know. and read whatever is being there at that time. I can not evem guess what you are doing since you are insulting me by asking me to look at uncommented code. Erik Erik
hello Mr.Neo, no all the datas are garbage values while transmitting an array
hello Mr.Erik, sorry for uncommented codes. in my code, i am sending one character from hyperterminal to controller. Then iam sending '#' from controller to hyperterminal.all these things are happening perfectly. but when i transmit an array iam getting only garbage values in the hyperterminal. iam using 19200 baud rate. while(!RI); RI = 0; name = SBUF; TI = 0; SBUF = '#'; while(!TI); for(i = 0; i < 8; i++) { TI = 0; SBUF = hmi[i]; while(!TI); } i = 0;
So, in your code the '#' and '*' are transmitting correctly. THe problem is only with the array. Am I right?
hello Mr.Neo, yes ur correct, # and * are transmitting perfectly. but the array values are not transmitting(only garbage value is transmitting)
Is it possible that you are transmitting the contents of the array correctly but the data in the array is not what you expect? Just have a look at the array in the Watch window to check the contents. I'm not sure when the array will actually be initialised but either the start-up code or main function prologue code will do it. If that didn't succeed, then your array would contain 'garbage'. It's worth eliminating this possibility anyway.
hello Mr.Patrick, yes i checked in watch window, array content is similar to that one i initialized.
It seems like problem with the initialization of array. You first declare the array and next you initialize the array. Now you try.
What parity setting is Hyperterminal using? I note that '#' and '?' characters have an odd number of high bits in their ascii coding while '0' and '3' have an even number of high bits.
hello Mr.Patrick, not only with 0's with any character only garbage value is transmitting