SPI Init triggers old NRF_SPIM_EVENT_END

vit bernatik gravatar image

asked 2017-02-17 18:35:58 +0100

Hello, We are sharing SPI and we found possible bug in nrf_drv_spi....

The problem was that first SPI is using blocking SPI thus does not use ISR and set it to NULL:

nrf_drv_spi_init(&spi, &spi_config, NULL)

Then I try to reuse SPI and I call

nrf_drv_spi_init(&g_spi, &g_spi_config, spi_event_handler)

But the problem is that interrupt EVENTS_END is pending and as soon as I init SPI I get interrupt that SPI trasfer was done. My handler is called and it reacts to end of transfer. Which breaks the protocol and everything....

I think that EVENTS_END shall be called by driver either in function nrf_drv_spi_uninit() or maybe in function nrf_drv_spi_init().

What do you think?

Can you fix it in future SDK?

So far workaround and correct init shall be:

nrf_spim_event_clear((NRF_SPIM_Type*)g_spi.p_registers, NRF_SPIM_EVENT_END);
nrf_drv_spi_init(&g_spi, &g_spi_config, spi_event_handler)
edit retag flag offensive close delete report spam

1 answer

Sort by ยป oldest newest most voted
hungbui gravatar image

answered 2017-02-20 13:13:45 +0100

Hi Vit,

It does seem like a bug with the spi driver. We should clear pending event when we uninit the SPI. I would suggest to put nrf_spim_event_clear() inside nrf_drv_spi_uninit(). I will report this internally.

edit flag offensive delete publish link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer. Do not ask a new question or reply to an answer here.

[hide preview]

Question Tools

1 follower


Asked: 2017-02-17 18:35:58 +0100

Seen: 143 times

Last updated: feb. 20