I''m trying to run a piece of PERIPHERAL example code running on a nrf51422 devboard
I'm using sdk 8.0 and the example's relative path is:
>nRF51_SDK_8.1.0_b6ed55f\examples\peripheral\uart
Now, this is what I'm hoping for. In most other examples, there's gonna be this initialization function where an interrupt handler will be present. I do modification to that handler, press ctrl-c, press ctrl-v and viola! My project moves forward by 80%.
This specific example however, deoesn't seem to operate by that principle. I found the interrupt handler, this to be more precise:
void UART0_IRQHandler(void)
{
// Handle reception
if (NRF_UART0->EVENTS_RXDRDY != 0)
{
uint32_t err_code;
// Clear UART RX event flag
NRF_UART0->EVENTS_RXDRDY = 0;
// Write received byte to FIFO
err_code = app_fifo_put(&m_rx_fifo, (uint8_t)NRF_UART0->RXD);
if (err_code != NRF_SUCCESS)
{
app_uart_evt_t app_uart_event;
app_uart_event.evt_type = APP_UART_FIFO_ERROR;
app_uart_event.data.error_code = err_code;
m_event_handler(&app_uart_event);
}
// Notify that new data is available if this was first byte put in the buffer.
else if (FIFO_LENGTH(m_rx_fifo) == 1)
{
app_uart_evt_t app_uart_event;
app_uart_event.evt_type = APP_UART_DATA_READY;
m_event_handler(&app_uart_event);
}
else
{
// Do nothing, only send event if first byte was added or overflow in FIFO occurred.
}
}
// Handle transmission.
if (NRF_UART0->EVENTS_TXDRDY != 0)
{
// Clear UART TX event flag.
NRF_UART0->EVENTS_TXDRDY = 0;
on_uart_event(ON_TX_READY);
}
// Handle errors.
if (NRF_UART0->EVENTS_ERROR != 0)
{
uint32_t error_source;
app_uart_evt_t app_uart_event;
// Clear UART ERROR event flag.
NRF_UART0->EVENTS_ERROR = 0;
// Clear error source.
error_source = NRF_UART0->ERRORSRC;
NRF_UART0->ERRORSRC = error_source;
app_uart_event.evt_type = APP_UART_COMMUNICATION_ERROR;
app_uart_event.data.error_communication = error_source;
m_event_handler(&app_uart_event);
}
}
I placed a break point at
if (NRF_UART0->EVENTS_RXDRDY != 0)
and then I set the breakpoint hitcount to 6.
After the break point were hit 6 times I took a look at the RXD register in my keil watch 2 window, nothing, all 0s. The TXD has a value but that doesn't really mean anything.
What I' want is that I want a interrupt handler that I can migrate with ease, or at least I can view the content of what has been received on my devboard.
So... what did I do wrong? Why is the RXD register always zeros? Anything I forgot to enable?