Dear Nordic developers,
SPI_MASTER peripheral behaves in a way, that I cannot understand from manual is it normal or no.
I have implemented something similar to loopback example. After initialization I'm writing first byte to the TXD register and immediately after the first one second byte. (as it has double buffer). As I expect, I'm getting two READY events. In a first READY event I'm reading RXD register two times and I get expected two values already in a first READY event.
I was thinking that I should get first byte in a first READY event and the second byte in a second READY event. My simplified code is bellow.
void SPI0_TWI0_IRQHandler(void)
{
if ((NRF_SPI0->EVENTS_READY == 1) && (NRF_SPI0->INTENSET & SPI_INTENSET_READY_Msk))
{
NRF_SPI0->EVENTS_READY = 0;
if (first_ready_event)
{
rx_data[0] = (uint8_t)spi_base->RXD;
rx_data[1] = (uint8_t)spi_base->RXD;
}
if (second_ready_event)
// do nothing
}
}
int main()
{
while(true)
{
master_spi->TXD =cnt;
master_spi->TXD =cnt + 1;
nrf_delay_us(100);
}
}
I'd really appreciate if someone could help me and clarify all this.
Thanks and regards, Harut