hi,
i want to program a nrf52 with Keil. Now im looking for an easy way to see my serial messages (printf) is there any toutorial?
Thanke You;)
hi,
i want to program a nrf52 with Keil. Now im looking for an easy way to see my serial messages (printf) is there any toutorial?
Thanke You;)
The multilink example has printf to a serial port. See APPL_LOG(""); in main.c
enable it by putting ENABLE_DEBUG_LOG_SUPPORT in the defines in; Menu,project,options,C/C++,Preprocessor Symbols
As already mentioned, using an example with the app_uart_fifo driver is a good start. This driver will have the least effect on the timing in the application, as the printf() serial data will be interrupt driven.
An alternative can be to use the simple_uart driver, however then the printf() serial data is not interrupt driven, so it will introduce delays in the code, the implementation though is much simpler. It can also be called from high level interrupts without problems:
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "app_uart.h"
#include "app_error.h"
#include "nrf.h"
#include "bsp.h"
#include "simple_uart.h"
int fputc(int ch, FILE * p_file)
{
simple_uart_put((uint8_t)ch);
return ch;
}
int main(void)
{
simple_uart_config(RTS_PIN_NUMBER, TX_PIN_NUMBER, CTS_PIN_NUMBER, RX_PIN_NUMBER, HWFC);
printf("\n\rStart:");
while (true)
{
uint8_t cr = simple_uart_get();
simple_uart_put(cr);
}
}
In projects using UART for debugging, it might be a good idea to disable hardware flow control and have a pull up on the RXD line. This way if you plan to run the board without connected to a serial port, the driver will not fail due to UART framing errors or buffer overrun.
As an alternative to UART might be to check out debugging with real time terminal.