Hello all, i try to execute the following program under µVision-V4.00-Simulator but the Serial Window shows nothing. By debugging the programm comes to rest upon sth putchar('A');
Please help me.
Thanks
the code is: ======================================================= #include <LPC21xx.H> #include <stdio.h>
int main(void) { UART0 (); //Initilise the UART
putchar('A'); while(1) { printf("\n\n\nHello World, well its traditional \n"); //Call the prinff function
}
} /****************************************************/ void UART0 (void) { PINSEL0 = 0x05; // Select TxD and RxD on pin connect block U0LCR = 0x80; //Enable programming of divisor latches
U0DLL = 0xC2; //Program the divisor latch for 19200 baud U0DLM = 0x00;
U0LCR = 0x33; //Program the line control 8\N\1 U0FCR = 0x4F; //enable the FIFO's
} /****************************************************/ #define CR 0x0D
#include <LPC21xx.H> int putchar (int ch);
int putchar (int ch) { /* Write character to Serial Port */
if (ch == '\n') { while (!(U0LSR & 0x20)); U0THR = CR; /* output CR */ } while (!(U0LSR & 0x20));
return (U0THR = ch); }
Hello Martin,
1000 Thanks for your advice. There is a very importent C-codes in the Retarget.c:
#include <stdio.h> #include <rt_misc.h>
#pragma import(__use_no_semihosting_swi)
extern int sendchar(int ch); /* in serial.c */
struct __FILE { int handle; /* Add whatever you need here */ }; FILE __stdout;
int fputc(int ch, FILE *f) { return (sendchar(ch)); }
int ferror(FILE *f) { /* Your implementation of ferror */ return EOF; }
void _ttywrch(int ch) { sendchar(ch); }
void _sys_exit(int return_code) { label: goto label; /* endless loop */ }