Hello,
I am trying to send "Hello" through the UART and the nrf52840 dongle using a USB to TTL approach. The main.c code and the sdk_confg.h are uploaded here. The problem is that neither printf nor the NRF_LOG_INFO command shows nothing at the serial monitor!
Please note that in the configuration, ble, uart, spi, and PWM is enabled since this is the final thing that I need.
I have done the ble+pwm+spi and it works fine. The only problem now is that I need UART to see the SPI data and this simple code for the UART does not work!
BTW, I have checked the USB to ttl and it works fine. I have used to Arduino to send hello using uart with that and it works!
Can you please help me with this part?
Thanks,
Abbas
#include "nrf_drv_spi.h"
#include "app_util_platform.h"
#include "nrf_gpio.h"
#include "nrf_delay.h"
#include "boards.h"
#include "app_error.h"
#include <string.h>
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"
//UART
#include "nrf_uart.h"
#include "app_uart.h"
// I have also added APP_UART_ENABLED and APP_FIFO_Enabled in the sdk_confg
// Also I have added app_fifo and app_uart.h path to the Keil
//UART
#define UART_TX_BUFF_SIZE 128 // TX buffer size
#define UART_RX_BUFF_SIZE 128 // RX Buffer size
#define UART_HWFC APP_UART_FLOW_CONTROL_DISABLED
// A simple error handler for uart if something goes wrong...
void uart_err_handle(app_uart_evt_t * p)
{
}
int main(void)
{
uint32_t err_code; // a variable to hold the error value
bsp_board_init(BSP_INIT_LEDS); // initialize leds
const app_uart_comm_params_t com_params = // struct to hold the uart configurations
{
#define RX_PIN_NUMBER NRF_GPIO_PIN_MAP(0,29),
#define TX_PIN_NUMBER NRF_GPIO_PIN_MAP(0,02),
#define RTS_PIN_NUMBER UART_PIN_DISCONNECTED,
#define CTS_PIN_NUMBER UART_PIN_DISCONNECTED,
UART_HWFC, // hardware flow control disabled
false, // parity = none
NRF_UART_BAUDRATE_115200 // set this baud rate for communication
};
// pass all the values to this function to initialize the UART module
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); // check if everything initialized correctly
while(1)
{
printf("Hello PC from nordic Device!!\r\n");
nrf_delay_ms(1000);
NRF_LOG_INFO("Hello!\r\n");
bsp_board_led_invert(BSP_BOARD_LED_2);
nrf_delay_ms(4000);
bsp_board_led_invert(BSP_BOARD_LED_2);
nrf_delay_ms(1000);
} // while loop closed
} // main function closed
/** @} */