I have LPC1768 based board - LandTiger (worth checking manual at the bottom). To program it I use Keil uVision4/72 Lite and J-Link EDU from Segger. My simple program to interact with joystick and diodes works fine, but...
I am trying to implement debug printf, so I can see printf output in Keil "Debug (printf) Viewer" window. Problem is that I dont see any output - I think I am on right track because when I run the debugger I can see Trace:Running at the bottom of the window (before it was Trace:No Synchronization). Unfortunately I dont see anything in UART and Debug output windows.
I've spent quite a lot of time trying to make it work and would appreciate any help, thank you ;)
My Keil settings are:
Project/Options for Target/Debug set to J-Link/J-Trace Cortex.
Then inside it's settings I have SEGGER selected with Port:SW and MAX CLOCK:10 MHz.
Trace tab is enabled with 100Mhz Core Clock and SWO Prescaler = 17 (which results in 5.882352MHz SWO Clock).
ITM Stimulus Ports are set to Enable:0xFFFFFFFF and Privilege:0x0000000F
Here are parts of my code:
define FOSC 12000000
define FCCLK (FOSC * 8)
define FCCO (FCCLK * 3)
define FPCLK (FCCLK / 4)
define UART0_BPS 115200
void UART0_Init (void)
{
uint16_t usFdiv;
/* UART0 */
LPC_PINCON->PINSEL0 |= (1 << 4);/* Pin P0.2 used as TXD0 (Com0) */
LPC_PINCON->PINSEL0 |= (1 << 6);/* Pin P0.3 used as RXD0 (Com0) */
LPC_UART0->LCR = 0x83;
usFdiv = (FPCLK / 16) / UART0_BPS;
LPC_UART0->DLM = usFdiv / 256;
LPC_UART0->DLL = usFdiv % 256;
LPC_UART0->LCR = 0x03;
LPC_UART0->FCR = 0x06;
}
Sending code:
int UART0_SendByte (int ucData)
{
while (!(LPC_UART0->LSR & 0x20)){};
return (LPC_UART0->THR = ucData);
}
And my fputc for printf (it is called - checked)
int fputc(int c, FILE *f)
{
if (c == '\n') {
UART0_SendByte('\r');
}
return (UART0_SendByte(c));
}
Any ideas?
Regards!
printf
sends data to the debugger IDE through the debug port (JLink in your case). So either youprintf
and don't override thefputc
, and expect the output on the debug window, or you send to UART, connect the RS232 to the PC and see it on hyperterminal or something like that. I'm probably missing something. – Balau