7 posts / 0 new
Last post
ramapra
Offline
Last seen:3 years 10 months ago
加入:2014-02-06 02:58
Printing stuff

Newbie question - Whats the easiest way to print something ( like printf) and how do i view this in the IDE?
Are there better ways to print and capture output?

gl_dialog
Offline
Last seen:3 years 3 months ago
Staff
加入:2014-02-07 13:35
Dear RAMAPRA,

Dear RAMAPRA,

I am not sure what you meant.
是什么you want to print? which output do you need to capture?
Thanks,

best regards,

DIALOG SUPPORT TEAM.

smarly
Offline
Last seen:2 years 2 weeks ago
Master
加入:2014-02-05 14:50
Same question for me: how to

Same question for me: how to add a simple printf ?
In proximity reporter full hosted project, I have added the following define: "CFG_PRINTF". AT the end of uart_init, I add the line:
uart_write("uart_is_initialised",19,NULL);
This one is working.
But if I add other uart_write in the code, (e.g at the end of app_init_func), it does not work.
How to make some printf(redirected to serial port/FTDI) anywhere in the code ?

avlasov1
Offline
Last seen:6 years 6 months ago
加入:2014-05-15 16:58
I also have the same question

I also have the same question. It would be useful to be able to use a print statement for debugging purposes. There is a good implementation in the peripheral example's uart.c, how could I implement the same printf_string() function in the proximity reporter project? The uart_write() function does not seem to be working for me (no visible output in keils or in TeraTerm).

Thanks

Joacimwe
Offline
Last seen:1 year 2 months ago
Guru
加入:2014-01-14 06:45
Hi. You need to set up the

Hi. You need to set up the pins and clock first.
uart_init() is for some odd reason not enough.

Open periph_setup.c.

In GPIO_reservations(void), add the following:

RESERVE_GPIO( UART1_TX, GPIO_PORT_0, GPIO_PIN_4, PID_UART1_TX);
RESERVE_GPIO( UART1_RX, GPIO_PORT_0, GPIO_PIN_5, PID_UART1_RX);

In periph_init(void), before calling patch_func(), add this:

SetBits16(CLK_PER_REG, UART1_ENABLE, 1); // enable clock - always @16MHz
uart_init(UART_BAUDRATE_115K2, 3);

Now you can use uart_print.

avlasov1
Offline
Last seen:6 years 6 months ago
加入:2014-05-15 16:58
Thanks for the reply,

I was able to get it to work after adding what you said and adding these two lines into set_pad_functions() of periph_setup.c:

GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_4, OUTPUT, PID_UART1_TX, true);
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_5, OUTPUT, PID_UART1_RX, true);

Thanks for the help!

Joacimwe
Offline
Last seen:1 year 2 months ago
Guru
加入:2014-01-14 06:45
Sorry, I forgot that. However

Sorry, I forgot that. However, I put false instead of true in the last argument.

For those who don't know, this example code is included in the sdk if you search enough deep in the directory tree...