Hi,
I add UART support using IRQ on the "ant_hrm_tx" example code.
and I'm sending packet of 4 bytes that contains: Delimiter,HeartRate,Battery,Delimiter
the frame is very basic and send every 1000ms from another MCU.
the problem is that I can see the "printf messages" (on the demo) but Ican't received any message (breakpoint inside the IRQ handler)
here's our IRQ handler, based on uart example code:
the basic concept is to extract the HeartRate from the frame and to send it using the hr.
/**@brief UART0 IRQ handler */
void UART0_IRQHandler(void)
{
if (NRF_UART0->EVENTS_RXDRDY == 1)
{
data_array[index++] = (uint8_t)NRF_UART0->RXD;
NRF_UART0->EVENTS_RXDRDY = 0;
if (data_array[0] != 0xFE) //find sync
index = 0;
if (index == 4)
{
index = 0;
if (data_array[3] == 0xFE)
{
heart_rate = (uint16_t)data_array[1];
data_array[0]=0;
data_array[3]=0;
}
}
} }
/**@brief UART configure */
void uart_config(uint8_t txd_pin_number,uint8_t rxd_pin_number) { 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;
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 = 0; NRF_UART0->TASKS_STARTRX = 1; //RX only NRF_UART0->EVENTS_RXDRDY = 0; }
/**@brief UART init: pinout, speed and IRQ */
static void uart_init(void)
{
uart_config(TX_PIN_NUMBER, RX_PIN_NUMBER);
NRF_UART0->INTENSET = UART_INTENSET_RXDRDY_Enabled << UART_INTENSET_RXDRDY_Pos;
NVIC_SetPriority(UART0_IRQn, APP_IRQ_PRIORITY_HIGH); NVIC_EnableIRQ(UART0_IRQn);
}
I really need you help here, did I missed something with the registers? IRQ mask? how can we integrate UART RX using ANT stack, also when nRF51422 is sleeping?
many thanks,