Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 2 months ago.
SPI.transfer not hitting callback (STM32)
I am using an STM32L476RG running mbedOS on a custom board. I am using the SPI library and calling a transfer function. I have used this setup with I2C.transfer() as well. Typically my callback is hit whether or not the transfer was a success (or in the case of I2C, a NACK ACK or failure). But recently I have been having issues with the callback not getting hit on the SPI call. I have known noise issues on my power bus and am currently working of dealing with those, but I am not sure if that would prevent the SPI peripheral from completing an operation.
The callback gets hit most of the time, but if it does not get called one time it will block my code (before the workaround I've done). So, at least at this point, it seem erratic.
I have worked around this by waiting for the callback to get hit (using EventFlags, which are set in the callback) and if the timeout is hit I will abort all transfers on the SPI bus.
Any ideas on which situations would prevent the SPI callback from getting hit?
SPI port; /* Just added for clarity in mbed forum, constructor and setup is called elsewhere */ void ssc_spi_callback( int argument ){ /* Set mbed EventFlags */ } ... while( TRANSFER_STARTED != et1100_spi_handle->port->transfer( tx_buffer, tx_length, rx_buffer, rx_length, ssc_spi_callback, SPI_EVENT_COMPLETE ) ) { wait_ms( SPI_RETRY_DELAY_MS ); }; ...