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

UART RX executed when connected via BT

Hi,

I have the following code with SD110 7.1.0:

static void uart_init(void) // device inter-communication
{

// Configure RX and TX pins.
nrf_gpio_pin_set(0);
nrf_gpio_cfg_output(0);
nrf_gpio_cfg_input(0, NRF_GPIO_PIN_PULLUP);


NRF_UART0->PSELTXD = 0;
NRF_UART0->PSELRXD = 1;

// Configure baud rate and parity.
NRF_UART0->BAUDRATE = (115200 << UART_BAUDRATE_BAUDRATE_Pos);

NRF_UART0->CONFIG = (UART_CONFIG_PARITY_Excluded << UART_CONFIG_PARITY_Pos);

NRF_UART0->ENABLE        = (UART_ENABLE_ENABLE_Enabled << UART_ENABLE_ENABLE_Pos);
NRF_UART0->EVENTS_RXDRDY = 0;
NRF_UART0->EVENTS_TXDRDY = 0;

NRF_UART0->CONFIG       &= ~(UART_CONFIG_HWFC_Enabled << UART_CONFIG_HWFC_Pos);

#define  UART_PIN_DISCONNECTED 0xFFFFFFFF /**< Value indicating that no pin is connected to this UART register. */

NRF_UART0->PSELRTS       = UART_PIN_DISCONNECTED;
NRF_UART0->PSELCTS       = UART_PIN_DISCONNECTED;

NRF_UART0->TASKS_STARTTX = 1;
NRF_UART0->TASKS_STARTRX = 1;

// Enable UART interrupt
NRF_UART0->INTENCLR = 0xffffffffUL;
NRF_UART0->INTENSET = (UART_INTENSET_RXDRDY_Set << UART_INTENSET_RXDRDY_Pos) |
                      (UART_INTENSET_TXDRDY_Set << UART_INTENSET_TXDRDY_Pos) |
                      (UART_INTENSET_ERROR_Set << UART_INTENSET_ERROR_Pos);

NVIC_ClearPendingIRQ(UART0_IRQn);
NVIC_SetPriority(UART0_IRQn, APP_IRQ_PRIORITY_LOW);
NVIC_EnableIRQ(UART0_IRQn);
}

/**@brief Function for handling the UART Interrupt.
 *
 * @details UART interrupt handler to process TX Ready when TXD is available, RX Ready when a byte
 *          is received, or in case of error when receiving a byte.
 */
void UART0_IRQHandler(void)
{
// Handle reception
if ((NRF_UART0->EVENTS_RXDRDY != 0) && (NRF_UART0->INTENSET & UART_INTENSET_RXDRDY_Msk))
{
    // This event executed when connected via BT (from phone)
    // Clear UART RX event flag
    NRF_UART0->EVENTS_RXDRDY  = 0;
    uart_rx_buff[in_wr_ptr++] = (uint8_t)NRF_UART0->RXD;
	if(in_wr_ptr >= sizeof(uart_rx_buff))
	{
		in_wr_ptr = 0;
	}
}

// Handle transmission.
if ((NRF_UART0->EVENTS_TXDRDY != 0) && (NRF_UART0->INTENSET & UART_INTENSET_TXDRDY_Msk))
{
    // Clear UART TX event flag.
    NRF_UART0->EVENTS_TXDRDY = 0;
    //on_uart_event(ON_TX_READY);
}

// Handle errors.
if ((NRF_UART0->EVENTS_ERROR != 0) && (NRF_UART0->INTENSET & UART_INTENSET_ERROR_Msk))
{
    uint32_t       error_source;

    // Clear UART ERROR event flag.
    NRF_UART0->EVENTS_ERROR = 0;

    // Clear error source.
    error_source        = NRF_UART0->ERRORSRC;
    NRF_UART0->ERRORSRC = error_source;
}
}

Could anybody explain me why receive RX event when I connect via BT? I don't use UART through BT just I want to use UART module of this chip via pin1-2 (RX-TX only)

Thanks!

Related