Hello,
I have an application that I receive data over the UART. The data being received can be of different lengths e.g. 12 bytes up to a maximum of 256 bytes. I want to know when the data coming in has stopped, so I know when to read the buffer. I've been reading the UARTE — Universal asynchronous receiver/transmitter with EasyDMA page, and it mentions using RXTO to know when the RX has stopped.
I've set the UARTE up, but I don't know how to setup or use the RXTO.
I've used the UART example code, and modified it by changing the main code. I can toggle and LED from the UARTE1_IRQHandler, but the "hello" is not being transmitted.
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "app_uart.h"
#include "app_error.h"
#include "nrf_delay.h"
#include "nrf.h"
#include "bsp.h"
#include "nrf_uarte.h"
uint8_t UARTE_RX_BUF = 10;
uint8_t UARTE_TX_BUF = 10;
void UARTE1_IRQHandler(void)
{
if(nrf_uarte_event_check(NRF_UARTE1, NRF_UARTE_EVENT_RXDRDY)) {
nrf_uarte_event_clear(NRF_UARTE1, NRF_UARTE_EVENT_RXDRDY);
nrf_gpio_pin_toggle(LED_2);
nrf_uarte_task_trigger(NRF_UARTE1, NRF_UARTE_TASK_STARTRX);
}
}
void uarte_config(void)
{
nrf_uarte_txrx_pins_set(NRF_UARTE1, TX_PIN_NUMBER, RX_PIN_NUMBER);
nrf_uarte_baudrate_set(NRF_UARTE1, NRF_UARTE_BAUDRATE_115200);
nrf_uarte_configure(NRF_UARTE1, NRF_UARTE_PARITY_EXCLUDED, NRF_UARTE_HWFC_DISABLED);
nrf_uarte_enable(NRF_UARTE1);
nrf_uarte_event_clear(NRF_UARTE1, NRF_UARTE_EVENT_RXDRDY);
nrf_uarte_int_enable(NRF_UARTE1, NRF_UARTE_INT_RXDRDY_MASK);
nrf_uarte_rx_buffer_set(NRF_UARTE1, &UARTE_RX_BUF, 10);
nrf_uarte_tx_buffer_set(NRF_UARTE1, &UARTE_TX_BUF, 10);
NVIC_SetPriority(UARTE1_IRQn, 3);
NVIC_ClearPendingIRQ(UARTE1_IRQn);
NVIC_EnableIRQ(UARTE1_IRQn);
}
int main(void)
{
uint32_t err_code;
uarte_config();
bsp_board_init(BSP_INIT_LEDS);
uint8_t data[] = "Hello";
nrf_uarte_task_trigger(NRF_UARTE1, NRF_UARTE_TASK_STARTRX);
nrf_uarte_tx_buffer_set(NRF_UARTE1, data, 5);
nrf_uarte_task_trigger(NRF_UARTE1, NRF_UARTE_TASK_STARTTX);
while (true)
{
}
}