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); } }
Are you linking with the default I/O routines from the default C-library? I guess you don't invoke them from your Assembler module but rather use your own I/O functions. The C-library functions can be customized by modifying the source files GETKEY.C and PUTCHAR.C. (Applies to C51 COMPILER V5.10. I know, it isn't exactly up-to-date.) Good Luck Norbert
"The C-library functions can be customized by modifying the source files GETKEY.C and PUTCHAR.C." Yes, this is still true in the latest version! Have you tried it in the simulator?
No. Should I? I've just quoted the manual. We write directly to S0BUF. You can derive by induction, that my suggestion will work: Let A be customization of ?C_START Let B be customization of BANK_LINKING Let C be integration(ASM,C) Let D be another Feature, not mentioned yet. Keil's Feature A worked so far. Keil's Feature B worked so far. Keil's Feature C worked so far. Keil's Feature D worked so far. ----------------------------- This Feature will work either. :)
View all questions in Keil forum