Trying to use SPI emulator (AN4678) on STM32F405
- February 13, 2024
- 2 replies
- 2022 views
Hello,
I'm trying to read some data using the RX mode of the SPI emulator explained in AN4678 but I have a weird bug that I don't know how to fix.
To quickly explain how it works, the SPI emulator uses TIM1 pin to generate a clock and a GPIO pin to behave like a MISO pin. In my case, the STM32 chip is configured as the master (Master Emulation, Slave HW). Using DMA Peripheral to Memory, data is read from the GPIO and stored in a variable at each clock edge of the TIM1 pin. The emulator uses flags to indicate when the transmission is complete.
When I try to read data just once, the data retrieval works fine and the good amount of rising edges are sent. But when I want to use the function several times, it seems that the reading process is not finishing properly and the CLK pin is not sending the right amount of rising edges. I don't know if completely resetting the timer and GPIO clocks might work, because if i "restart" the whole driver from zero it should work like the first time ? I tried briefly but it doesn't seemed to work.
Can anyone give me an advice ?
The application note used is attached.
Thank you