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.
I want to have a simple program to print something out using hyperterminal. Also it would be nice to receive a character and echo it back. I have been able to do this in assembly but I can't get it to work in C. Here is the latest code I have tried:
#include <AT89X51.H> #include <CTYPE.H> #include <STDIO.H> int i; void main() { SCON = 0x50; //SCON: mode 1, 8-bit UART, enable rcvr TMOD = 0x20; //TMOD: timer 1, mode 2, 8-bit reload TH1 = 0xFD; //TH1: reload value for 9600 baud @ 11.0592MHz TR1 = 1; //TR1: timer 1 run TI = 1; //TI: set TI to send first char of UART while (1) { P1 ^= 0x01; printf ("\n\nHello World\n\n"); i = _getkey(); putchar('$'); putchar(i); } }
I reviewed the messages and am not sure whether you tried stepping into your C program using the simulator. I have found this a good tool for both the asynch serial comm and the clocks. The simulator will show you how you have set the baud and will display sbuf. Run the simulator with your assy code and record the ports' setup bits. Run again with your C code and compare the ports' setup bits. This may allow you to confirm if you are setting up the ports properly.