2015-02-14 05:57 AM
Hi, the code for my interrupt handler is below
void SPI_IRQHandler(SPI_TypeDef * SPIx){ uint8_t SPIn = (SPIx == SPI1) ? 0 : ((SPIx == SPI2) ? 1 : 2); if(SPI_I2S_GetITStatus(SPIx, SPI_I2S_IT_RXNE) == SET) { if(_RxCounter[SPIn] < _RxNumData[SPIn]) { if(_RxBuffer[(SPIx == SPI1) ? 0 : ((SPIx == SPI2) ? 1 : 2)]) { _RxCounter[SPIn]++; _RxBuffer[SPIn][_RxCounter[SPIn] - 1] = SPI_I2S_ReceiveData(SPIx); SPI_RX_UserCallback(SPIx, _RxBuffer[SPIn], &_RxNumData[SPIn]); } else SPI_I2S_ReceiveData(SPIx); } else if(_RxCounter[SPIn] == _RxNumData[SPIn]) { if(_RxBuffer[(SPIx == SPI1) ? 0 : ((SPIx == SPI2) ? 1 : 2)]) { SPI_I2S_ITConfig(SPIx, SPI_I2S_IT_TXE, DISABLE); SPI_I2S_ITConfig(SPIx, SPI_I2S_IT_RXNE, DISABLE); while(SPI_I2S_GetFlagStatus(SPIx, SPI_I2S_FLAG_BSY) == SET); spi_ready(SPIx); SPI_RXTC_UserCallback(SPIx, _RxBuffer[SPIn], &_RxNumData[SPIn]); } } } if(SPI_I2S_GetITStatus(SPIx, SPI_I2S_IT_TXE) == SET) { if(_TxCounter[SPIn] < _TxNumData[SPIn]) { if(_TxBuffer[(SPIx == SPI1) ? 0 : ((SPIx == SPI2) ? 1 : 2)]) { _TxCounter[SPIn]++; SPI_I2S_SendData(SPIx, _TxBuffer[SPIn][_TxCounter[SPIn] - 1]); SPI_TX_UserCallback(SPIx, _TxBuffer[SPIn], &_TxNumData[SPIn]); } else SPI_I2S_SendData(SPIx, (SPIx == SPI1) ? DUMMY1 : ((SPIx == SPI2) ? DUMMY2 : DUMMY3)); } else if(_TxCounter[SPIn] == _TxNumData[SPIn]) { if(_TxBuffer[SPIn]) { SPI_I2S_ITConfig(SPIx, SPI_I2S_IT_TXE, DISABLE); while(SPI_I2S_GetFlagStatus(SPIx, SPI_I2S_FLAG_BSY) == SET); spi_ready(SPIx); SPI_TXTC_UserCallback(SPIx, _TxBuffer[SPIn], &_TxNumData[SPIn]); } } }}I am getting 2 extra bytes of clock pulse while receiving data from the flash memory (SPI communication). Why am I getting this problem and How to rectify it ? Any kind of help would be appreciated. Thank You. #stm32f4 #discovery #spi #flash2015-02-14 11:36 AM
Are the unexpected bytes a result of sending the command/address to the SPI device?
2015-02-14 08:12 PM
NO, there is a separate pulse for sending the address. It is only while receiving that I am getting 2 extra bytes of pulses.
From: clive1Posted: Saturday, February 14, 2015 8:36 PMSubject: stm32f4 spi problemAre the unexpected bytes a result of sending the command/address to the SPI device?