2014-06-19 12:42 PM
Hello,
I am interfacing an STM32F407 (on DISCOVERY eval) to several devices using SPI bus. One of the devices clocks 4 bytes of data out simultaneously as 4 bytes of config data is clocked in (LTC2446 ADC). I am attempting to use the HAL driver routine HAL_SPI_TransmitReceive_IT() to perform this transfer. I am finding that I only get 3 bytes and then the SPI hangs in a busy state. Has anyone used this driver and could perhaps tell if there is a limitation or different approach? I could bit-bang the SPI to the ADC, however, I have successfully interfaced to another SPI temperature sensor and don't have run-time to deinitialize the SPI driver, use GPIO for the ADC, then reinitialize SPI for the temperature sensor.2014-06-20 02:13 AM
2014-06-20 06:53 AM
Ok, so what is the correct way to clear a specific bit in the CR2? The referenced post recommended CR2 = ~MASK, however, if the MASK was TXEIE, ~MASK would set CR2 bits that may not have been already set.
2014-06-21 09:58 PM
2014-06-23 03:52 AM
Hi,
Since your are developing an application to interface the STM32F407 to several devices using SPI bus, it seems that the previous transfer is not properly finished. Thus, an overrun is may be detected when starting the HAL_SPI_TransmitReceive_IT() process. In this case, the first but is not received.Please try to clear the overrun flag using the macro: __HAL_SPI_CLEAR_OVRFLAG() before starting the process.With regards.2014-06-23 08:47 AM
Hi,
I tried your suggestion, __HAL_SPI_CLEAR_OVRFLAG(&hspi1), with no better results. Am I correct in understanding HAL_SPI_TransmitReceive_IT( ) routine that it is capable of full-duplex reading the received data whilst simultaneously transmitting the same number of bytes? Thanks in advance for your help, Mark