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

The RXDRDY is being written without having received message packet.

Hi,

I am trying to use the RX interrupt on the PCA10001 board, using UART0 for wired communication and S110 (s110_nrf51822_5.2.1) for Bluetooth LE communication at the same time.

Without have nothing connected on wire in RX port (without having received message packet) the EVENTS_RXDRDY is being written and it trigger the interrupt. If i clear the RXDRDY, he is written again.

Below some parts of my code, and i`m using:

#define HWFC           false

(I already define the HWFC true, it did not work.)


MAIN

#include <stdbool.h>
#include <stdint.h>
#include "nrf.h"
#include "simple_uart.h"
#include "nrf_gpio.h"
#include "boards.h"

    static void uart_init(void)
    {
        simple_uart_config(RTS_PIN_NUMBER, TX_PIN_NUMBER, CTS_PIN_NUMBER, RX_PIN_NUMBER, HWFC);

    
    NRF_UART0->INTENSET = UART_INTENSET_RXDRDY_Enabled << UART_INTENSET_RXDRDY_Pos;
    
    NVIC_SetPriority(UART0_IRQn, 2);
    NVIC_EnableIRQ(UART0_IRQn);

}
    
    void UART0_IRQHandler(void)
    {
    	if(NRF_UART0->EVENTS_RXDRDY==1)
    	{
Flag = 1    	
NRF_UART0->EVENTS_RXDRDY=0;
    	}
    }

int main(void)
{
	uart_init();
	while(true)
  {
		uint8_t cr = 'q';
		
		simple_uart_put(cr);
	}
  
}

Simple_Uart (from Uart example)

uint8_t simple_uart_get(void)
{
    while (NRF_UART0->EVENTS_RXDRDY != 1)
    {
        // Wait for RXD data to be received
    }

    NRF_UART0->EVENTS_RXDRDY = 0;
    return (uint8_t)NRF_UART0->RXD;
}

void simple_uart_put(uint8_t cr)
{
		NRF_UART0->TXD = (uint8_t)cr;

    while (NRF_UART0->EVENTS_TXDRDY != 1)
    {
        // Wait for TXD data to be sent.
    }

    NRF_UART0->EVENTS_TXDRDY = 0;
				
}

void simple_uart_config(uint8_t rts_pin_number,
                        uint8_t txd_pin_number,
                        uint8_t cts_pin_number,
                        uint8_t rxd_pin_number,
                        bool    hwfc)
{
/** @snippet [Configure UART RX and TX pin] */
    nrf_gpio_cfg_output(txd_pin_number);
    nrf_gpio_cfg_input(rxd_pin_number, NRF_GPIO_PIN_NOPULL);

    NRF_UART0->PSELTXD = txd_pin_number;
    NRF_UART0->PSELRXD = rxd_pin_number;

    if (hwfc)
    {
        nrf_gpio_cfg_output(rts_pin_number);
        nrf_gpio_cfg_input(cts_pin_number, NRF_GPIO_PIN_NOPULL);
        NRF_UART0->PSELCTS = cts_pin_number;
        NRF_UART0->PSELRTS = rts_pin_number;
        NRF_UART0->CONFIG  = (UART_CONFIG_HWFC_Enabled << UART_CONFIG_HWFC_Pos);
    }


    NRF_UART0->BAUDRATE      = (UART_BAUDRATE_BAUDRATE_Baud9600 << UART_BAUDRATE_BAUDRATE_Pos);
    NRF_UART0->ENABLE        = (UART_ENABLE_ENABLE_Enabled << UART_ENABLE_ENABLE_Pos);
    NRF_UART0->TASKS_STARTTX = 1;
    NRF_UART0->TASKS_STARTRX = 1;
    NRF_UART0->EVENTS_RXDRDY = 0;
}

Thanks!

Related