This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF52840 UART/UARTE not working

HI, all, 

       I am trying to transfer my previous project from nrf51822 to nrf52840, and at very the beginning ,I can not make the UART/UARTE of nrf52840  work. 

       0, I have programmed example hex file into 52840 to check the chip is OK and UART is OK, I can get data transmission from 52840 normally.

       1, I  tried to use nrf_uart.h to build the driver functions for UART,  since our previous project use it . However , when I watch the memory of the UART registers, I found that the function triggering STARTTX   nrf_uart_task_trigger(NRF_UART0, NRF_UART_TASK_STARTTX)  have no effect on the register TASKS_STARTTX which is located at 0x40002008, so data transmission did not happen. I have found when I operated other registers ,such as ENABLE, BAUDRATE and PSEL.TXD, data on the memory changed as  expected.

      2, I took reference from this link https://github.com/andenore/NordicSnippets/blob/master/examples/uart/main.c#L20 , trying to operate UARTE by setting register directly,  still STARTTX  can not be set.

       I have read about the STARTTX   in PS and searched in devzone,  and I have not found any restriction on setting that register, so I don`t know why that happened. 

   my code snap about UART is below, and I am using SDK16.0 ,the IDE is IAR8.22. the pin definition of my board is compatible with PCA10040 .   

   Any help and advice is appreciated! 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
BOOL BSP_Uart_Init(void)
{
if (s_tThisData.InitFlag) {
return False;
}
if ((GPIO_UART_TX > CH47) && (GPIO_UART_RX > CH47)) {
return False;
}
else {
memset(&s_tThisData, 0, SIZE(s_tThisData));
//nrf_uart_configure(NRF_UART0, NRF_UART_PARITY_EXCLUDED, NRF_UART_HWFC_DISABLED);
//nrf_uart_txrx_pins_set(NRF_UART0, GPIO_UART_TX, GPIO_UART_RX); //
//nrf_uart_int_enable(NRF_UART0, NRF_UART_INT_MASK_RXDRDY); //
NRF_UARTE0->CONFIG = (UART_CONFIG_HWFC_Disabled << UART_CONFIG_HWFC_Pos) |
(NRF_UART_PARITY_EXCLUDED << UART_CONFIG_PARITY_Pos);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX