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.
Hello everyone, I've been having some trouble getting output from my 8051. Some of the other forums haven't been of much help. I'm simply trying to send text from the 8051 to a terminal application. From the C51 example code, I have: #include <REG51F.H> #include <stdio.h> void main(void){ SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */ TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */ TH1 = 253; /* TH1: reload value for 1200 baud @ 16MHz */ TR1 = 1; /* TR1: timer 1 run */ TI = 1; /* TI: set TI to send first char of UART */ while(1){ printf("Test\n"); } } As a note though, I have an 11 MHz crystal, therefore, the above should set it to 9600 baud, not 1200. When I connect my term app at 9600, 8N1, no flow control, I get absolutely nothing. For giggles, I set it to 1200, 8N1, and I get a ton of garbage. Does anyone have any recommendations on things I can try to get proper output from the chip? I've got SecureCRT (but have also tried Hyperterminal, both with the same results)... Thanks in advance for your assistance!! -Ryan
Just to check, what chip are you using to convert the micro TX signal to RS232 level?
Hi Jon, thanks for the reply... I'm using a Maxim Max233CPP chip.. does that help at all? Thanks again!
Try
TH1 = 250; /* TH1: reload value for 9600 baud @11.059MHz */
Jon! You da man! 19200 is just fine for me.. I just needed SOMETHING... I changed my baud rate on my Term app, and I started getting output... How did you come up with 250 for 9600? All the books, tutorials, and examples I have say 253 for 9600. Thanks SO much!! -Ryan
Look here: http://www.keil.com/c51/baudrate.asp
For that mode: TH1 = 256 - Feq/192/baud
Okay, I'll whore myself again. I have several baud rate values calculated for several different crystal values in my free serial UART driver. Have a look at http://www.embeddedfw.com and look for the Free 8051 UART driver link at the bottom. I have an Excel spreadsheet I use for doing baud rate calcs. If anyone is interested I could post that too. - Mark