STM32 uC SPI slave

Viewed 26

I have an application which should implement an SPI slave protocol.

Each of the SPI transaction packets is supposed to have the same (known) number of bytes (let say 20 bayts).

Packets are send every 100us and also some part of the code (which process this packets) is executed every 100us. I try to implement this with DMA and when DMA receive all bytes, to trigger interrupt (HAL_SPI_RxCpltCallback).

On master I implemented to transmit known packets and at start everything goes good (slave receive exactly what master transmit), but after some time the data are shifted inside DMA buffer. It is possible that the master did not send some bytes, that the slave did not receive or that it exists some bug in HAL functions (i do not know that), but I cannot rely on DMA interrupt generation since I need execute part of code after exactly 100us (DMA iterrupt is called when buffer is full and if some bytes are lost inteerupt will not be generated).

Questions are:

  1. Does anyone know why bytes are shifted and if I noticed that what is the fastest way to reset buffer (SPI, DMA, or both).
  2. Since I use NSS functionality (e.g. on pin PA4), can I configure that this pin also generate GPIO interrupt on rising edge (EXTI)? In that case PA4 will have NSS and EXTI functionality.
0 Answers
Related