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

How to configure the UARTE0 correct?

Hi all

I'm struggling with the easyDMA UART of nrf52. I've got a preview nrf52-DK here where I wanted to make a simple example with the following code but I never reach the ENDRX event even if I send 20 or more bytes to the DK (pin 8). Also in debug mode I can't see that any byte reaches the rxbuffer.

Do you guys see why is that? What did I make wrong in the initiation?

Thank you all in advance for your support!

#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "nrf_delay.h"
#include "nrf_gpio.h"
#include "boards.h"
#include "nrf_uarte.h"

const uint8_t leds_list[LEDS_NUMBER] = LEDS_LIST;

void UARTE0_UART0_IRQHandler(){

	if(NRF_UARTE0->EVENTS_ENDRX){
		LEDS_INVERT(1 << leds_list[3]);
	}

}


int main(void)
{

	uint8_t txBuffer[20] = {0};
	uint8_t rxBuffer[20] = {0};

    NRF_UARTE0->BAUDRATE = NRF_UARTE_BAUDRATE_9600;
    NRF_UARTE0->PSEL.TXD = TX_PIN_NUMBER;
    NRF_UARTE0->PSEL.RXD = RX_PIN_NUMBER;
    NRF_UARTE0->CONFIG = NRF_UARTE_HWFC_DISABLED;
    NRF_UARTE0->ENABLE = (UARTE_ENABLE_ENABLE_Enabled << UARTE_ENABLE_ENABLE_Pos);

    NRF_UARTE0->TXD.PTR = (uint32_t)((uint8_t *) txBuffer);
    NRF_UARTE0->TXD.MAXCNT = sizeof(txBuffer);
    NRF_UARTE0->TASKS_STARTTX = 0;

    NRF_UARTE0->RXD.PTR = (uint32_t)((uint8_t *) rxBuffer);
    NRF_UARTE0->RXD.MAXCNT = sizeof(rxBuffer);
    NRF_UARTE0->TASKS_STARTRX = 1;


    NRF_UARTE0->INTENCLR = 0xFFFFFFFF;
    NRF_UARTE0->INTENSET = NRF_UARTE_INT_ENDRX_MASK;

    NVIC_ClearPendingIRQ(UARTE0_UART0_IRQn);
    NVIC_SetPriority(UARTE0_UART0_IRQn, 1);
    NVIC_EnableIRQ(UARTE0_UART0_IRQn);



    // Configure LED-pins as outputs.
    LEDS_CONFIGURE(LEDS_MASK);
    if(NRF_UARTE0->EVENTS_RXSTARTED){
    	LEDS_INVERT(1 << leds_list[1]);
    }


    while (true)
    {


    }
}
Parents
  • Hi, ran the exact same code on the preview kit and did receive the EVENTS_ENDRX with the correct data. Have you checked if tx works?

    Description of my setup:

    • on board Segger chip used as usb<->uart bridge
    • Terra term (serial terminal) on windows 7

    Just a note, generally you should have static allocation of your buffers, Although it shouldn't be a problem in this example.

    Attachment:

  • Hi, tried with GCC as well with the same result. LED was also inverted on EVENTS_ENDRX event. Are you using Eclipse managed make or using the SDK makefiles to build this project? Reason I ask is that there can be potentially be a problem with the build settings if Makefile is generated by Eclipse.

    Please try with the default UART example using Make outside of Eclipse just to see if UART is working at all. Building example applications in the command line is explained in the "before we begin" section here in case you haven't done it before.

Reply
  • Hi, tried with GCC as well with the same result. LED was also inverted on EVENTS_ENDRX event. Are you using Eclipse managed make or using the SDK makefiles to build this project? Reason I ask is that there can be potentially be a problem with the build settings if Makefile is generated by Eclipse.

    Please try with the default UART example using Make outside of Eclipse just to see if UART is working at all. Building example applications in the command line is explained in the "before we begin" section here in case you haven't done it before.

Children
No Data
Related