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?
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 ?
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).
Dear RAMAPRA,
I am not sure what you meant.
What do you want to print? which output do you need to capture?
Thanks,
best regards,
DIALOG SUPPORT TEAM.
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 ?
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
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.
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!
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...