Hi, I use IAR compiler and M16C/62P kit. I can't use printf() function. If I use it, compiler doesn't generate error or warning but I can't download the program to mcu. I define putchar and __low_level_put. I have a sample code from kickstart CD but I can't understand. Anybody have sample code or documents? void ConfigUart (void){ // Configure UART1 U1MR = 0x05; // 0000 0101: 8N1 format U1C0 = 0x10; // 0001 xx00: f1 UCON = 0x00; // x00x 00xx: Simple mode U1BRG = (CLOCK / 16 / BAUD) - 1; //Set the baud rate U1C1_bit.TE = 1; // Enable transmission U1C1_bit.RE = 1; // Enable reception PD6_bit.PD6_6 = 0; PD6_bit.PD6_7 = 1; // Set TXD1 as an output S1RIC = 5; //enable Uart1 receive interrupt } unsigned char getc(void){ if (RECEIVE==0) return 0x00; else return U1RBL; } void __low_level_put(unsigned char c) { // Called by putchar while (U1C1_bit.TI == 0); // Wait if the buffer is full U1TBL = c; // Send the next character } int putchar(int val) { // Called by printf if (val == '\n') __low_level_put('\r');// Convert EOL to CR/LF __low_level_put(val); return val; }
m16c IAR printf
Started by ●May 12, 2005
Reply by ●May 13, 20052005-05-13