2020-02-25 12:59 AM
hi,
I'm new in ST. I'm trying to implement SPI communication between FPGA and STM32L051R8T6 (slave).
I've initialized the spi bus in main (HAL_SPI_Init()), so that it is set to use (HAL_SPI_RxCpltCallback).
and from main i called HAL_SPI_Receive_IT (to recieve 2 bytes).
I am expecting that after the 2 bytes recive HAL_SPI_RxCpltCallback will be called and i could transmit back the data. however HAL_SPI_RxCpltCallback is not being called and it just complete the function and return to main
has anyone encountered this scenario before and could assist?
2020-02-25 04:57 AM
Hi. Did you enable interrupt for SPI?
Share your project.
2020-02-25 05:04 AM
what do you mean enable interrupt for SPI? i defined the spi ports using cube
2020-02-25 05:05 AM
should i done an additional setting to enable it?
2020-02-25 05:29 AM
In a previous post you mention that the MCU is running at 32 MHz, and SPI clock is 2 MHz.
It means that receiving one bit takes 500 ns, one byte takes 4 ms, which is 128 system clock cycles.
The HAL interrupt handler is not fast enough to process data at this speed.
Note that the STM32CubeL0 example projects set SPI clock to 125 kHz, i.e. 16 times slower.
Of course there are a lot of other stuff that can go wrong. Check that the interrupt handler (not the callback) is actually called, whether 0,1,2 bytes of the input buffer are changed.
Check SPI register values against the reference manual, assume neither that CubeMX generates correct code not that HAL functions work as you expect them to work.
2020-02-25 05:40 AM
thanks.