Hi,
I am writing my own SPIM driver, when I try to send a 2 bytes message and then a 26 bytes message the second message "crashes" after 2 bytes.
But if I send the 26 bytes message and then the 2 bytes message, the two messages are correctly sent.
Any known issue with TXD.MAXCNT ?
My code :
#define FLAG_CLEAR() NRF_SPIM0->EVENTS_ENDRX = 0;\
NRF_SPIM0->EVENTS_ENDTX = 0;\
NRF_SPIM0->EVENTS_STARTED = 0;\
NRF_SPIM0->EVENTS_STOPPED = 0;\
NRF_SPIM0->EVENTS_END = 0;
void SPI_setup()
{
NRF_SPIM0->ENABLE = 0;
NRF_SPIM0->PSEL.SCK = (SPI0_CLK_Port<<5UL) + SPI0_CLK_Pin;
NRF_SPIM0->PSEL.MISO = (SPI0_MISO_Port<<5UL) + SPI0_MISO_Pin;
NRF_SPIM0->PSEL.MOSI = (SPI0_MOSI_Port<<5UL) + SPI0_MOSI_Pin;
NRF_SPIM0->FREQUENCY = SPIM_FREQUENCY_FREQUENCY_M2;
NRF_SPIM0->CONFIG = SPIM_CONFIG_CPHA_Msk;
NRF_SPIM0->ENABLE = SPIM_ENABLE_ENABLE_Enabled;
}
void SPI_write(void* data, uint32_t length)
{
NRF_SPIM0->RXD.MAXCNT = 0;
NRF_SPIM0->TXD.PTR = (uint32_t)data;
NRF_SPIM0->TXD.MAXCNT = length;
NRF_SPIM0->TASKS_START = 1;
while(NRF_SPIM0->EVENTS_ENDTX == 0);
NRF_SPIM0->TASKS_STOP = 1;
FLAG_CLEAR();
}
When I send 2b and then 26b, you can see the weird crash with additional clock edges...
