문제

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!

도움이 되었습니까?

해결책

Your fputc sends bytes directly to the UART, which goes to the RS232 connector on board. If you want to see the output of your fputc, you need to connect a cable between the board and the PC and see it with a client such as hyperterminal.

When you talk about the trace capabilities, it generally means that the adapter (J-Link in your case) creates high throughput communication between the program and the debugger and follows the execution of the program. There are other debug functionalities. For example if you compile with semihosting, the program executes the system calls (_write, _open, ...) that are intercepted by the debugger that executes them on the host machine.

So in my experience either you call printf, don't override the fputc and compile with semihosting, and expect the output on the debug window, or you send to UART, connect the RS232 to the PC and see it on hyperterminal.

I see you found a third method which uses the trace capabilities. I believe the semihosting option is a more general solution because it can be applied also on a setup that doesn't have trace capabilities but just JTAG (or SWD) connection.

다른 팁

You want to write to the ETM cell with your printf command if you want the output to go to the SWD interface via the JLINK.

Follow the instructions in section 3.4 of http://cdn.energymicro.com/dl/an/pdf/an0043_efm32_debug_trace_capabilities.pdf.

Always check in your "printf" code that the last byte has gone out, otherwise output will not be correct.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top