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.
Hi, I'm french so excuse me for my English. I want to communicate with a PC and a 80c552 card made by myself, this with a serial link. I have no INT and just an emission of an octet from the 80c552 card to the PC. My problem is that the PC receives values but not the good one. In fact only FF is received correctly. I have made a communication between two PC so my program on the PC is ok. So the problem comes from the program loaded on the 80c552 and written with keil c51. I use the mode 1 of serial IO with SM1=1 and I have tried several speed from 2400 to 20000 bauds but nothing changed. I have no parity and just an octet with a start bit and a stop bit. Thanks for your help, please answer in english (your french is not so good...), and tell me if there is a better forum for this kind of problem. Florian
Today I am going to test pins with an oscilloscope. Here is the code: void initialisation_serie(void) { TMOD = 0x20 | ( TMOD & 0x0F ); TH1 = BAUDS_9600 ; TL1 = BAUDS_9600 ; PCON = 0x80 ; TR1 = 1; S0CON = 0x40 ; REN = 0; ES1 = 1 ; } void main(void) { initialisation_serie(); TR0=1; while(1) { if(TI==1) { TI=0; S0BUF=0xEE; } PCON |= 0x10 ; //watchdog T3 = 0; } }
Since you set PCON.7, your controller should run with a transmission rate of 19'200Bd. Is that what you wanted ? Your initialization of the control register S0CON resets REN, RI and TI. See my comments in your code to find what happens to TI.
S0CON=0x40; /* TI is S0CON.0, cleared now */
void main(void) { initialisation_serie(); /* TI=0 after initialization */ TR0=1; while(1) { if(TI==1) /* TI is still 0, so the if */ /* condition will never come true... */ { TI=0; S0BUF=0xEE; }
ok I am going to try for TI. If I set PCON.7 to 0 the baudrate will be 9600 right?
Setting PCON.7 doubles the baudrate if Timer 1 is used to generate the internal clocks. If the baudrate was 19'200Bd, then clearing PCON.7 results in 9'600Bd. However, to find out if this results in 9600Bd for your application, you have to check the reload value for TH1. The reload value depends on the oscillator frequency and PCON.7. What frequency are you using and what is written to TH1 ? HHK
The value for TH1 is 0xF6, it must be good for 9600. But now I have an other problem because nothing is transmited now.
If you use the 12MHz Crystal, your PC would not be able to receive your characters correctly. Try the 11.038MHz Crystal
According to the baudrate calculation for an 8051 the reload value 0xF6 requires a clock frequency of appr. 36 Mhz. Is that true for your application ? HHK
Ok I have found the problem. I have to put a delay on the 80c552 because it is too fast for the PC. And there is a problem with the stop bit, it seems to be two stop stop bits, while I have configured anly one. Thank you for your help, I had a problem with my PC that's why I didn't answered since an hour. If anyone knows about this stop bit compatibility, thanks for the help...
ok, if I send 0000 1111, I receive 0001 1111 0000 0111 0000 1111 0000 1010 0001 1010 so a bit appears and I don't know why. the problem is always the same and works perfectly... it has been tested with a lot of values.
There is a baudrate calculator on the Keil web site at: http://www.keil.com/c51/baudrate.asp Note that is only works for the standard 8051-compatible UART using Timer 0 or Timer 1. For a reload value of F6, I couldn't figure out any NORMAL baudrate, but 36.8640 works (and it's a standard frequency). Anyway, maybe this link will help. Jon
The calculated frequency of 36.8640MHz is not specified for a PHILIPS 80C552. The maximum frequency depends on the device type. It is limited to 16, 24 or 30MHz. HHK
I have found my problem and everything works fine. It was a problem of speed, that's why there was a bit set to one in the octet. In fact 9300 or 10400 on the 80c552 wasn't close enough to 9600bds, that's why I modified the speed of the UART. For the 8052 uart of the PC you have to set the value to 0C to have a speed of 9600bds, so I modified it to 0D and it works. This value does not exist in the doc but it is closer to 9300 which is the speed of the 80c552. My english is not perfect so I hope everybody understood my solution.
Yep, Thanks for posting your solution. That's the biggest problem with serial connections to the PC. Jon