Hi,
I try to use UART in the template_project. But if I try to use printf UART doesn't work. The project works fine in debug mode. How can i fix the issue?
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "app_uart.h"
#include "app_error.h"
#include "nrf_delay.h"
#include "nrf.h"
#include "bsp.h"
#include "nrf_uart.h"
#define UART_TX_BUFF_SIZE 128
#define UART_RX_BUFF_SIZE 128
#define UART_HWFC APP_UART_FLOW_CONTROL_DISABLED
#define LED 8
void uart_err_handle(app_uart_evt_type_t *p)
{
}
int main(void)
{
uint32_t err_code;
nrf_gpio_cfg_output(LED);
const app_uart_comm_params_t com_params =
{
RX_PIN_NUMBER,
TX_PIN_NUMBER,
RTS_PIN_NUMBER,
CTS_PIN_NUMBER,
UART_HWFC,
false,
NRF_UART_BAUDRATE_115200
};
APP_UART_FIFO_INIT(&com_params, UART_RX_BUFF_SIZE, UART_TX_BUFF_SIZE, uart_err_handle, APP_IRQ_PRIORITY_LOWEST, err_code);
APP_ERROR_CHECK(err_code);
printf("Hello World!\r\n");
while(true)
{
uint8_t cr;
while( app_uart_get(&cr) != NRF_SUCCESS );// wait here until get character until from pc
if(cr == 't')
{
nrf_gpio_pin_write(LED, 1 );
printf("Leds Turned On!!\r\n");
}
if( cr == 'k')
{
nrf_gpio_pin_write(LED, 0 );
printf("Led Turned Off!!\r\n");
}
}