Part Number: TMS320F28027
Other Parts Discussed in Thread: DRV8305, MOTORWARE
Hi,
Have seen an issue with the below code (from the function DRV8305_readSpi in the file DRV8305.C), the line that checks for the status of the FIFO, records that there is a word in the buffer,however reading the result (incoming SPI word), at times this happens about 1% of the time, is reading the previously received word and not the latest one…..
So my suspicion was that for some reason the actual word has not yet fully been received (while you transmit 16bits, which started with the Write instruction, it takes time for all 16bits to be received), so I added some delay after the write and it solved the issue. BUT this is not a solution, we need to understand why it happening.
So the question is why would the buffer status comeback as valid with a word, while there is no word there? The status supposed to be resetted with the Reset of the SPI SPI_resetRxFifo(obj->spiHandle);??
Please let me know.
BTW, why are we reading the the EMU register and not RX register or better the FIFO?
// build the control word
ctrlWord = (uint16_t)DRV8305_buildCtrlWord(CtrlMode_Read,regAddr,data);
// reset the Rx fifo pointer to zero
SPI_resetRxFifo(obj->spiHandle);
SPI_enableRxFifo(obj->spiHandle);
// write the command
SPI_write(obj->spiHandle,ctrlWord);
// wait for the response to populate the RX fifo, else a wait timeout will occur
while((RxFifoCnt < SPI_FifoStatus_1_Word) && (WaitTimeOut < 0xffff))
{
RxFifoCnt = SPI_getRxFifoStatus(obj->spiHandle);
if(++WaitTimeOut > 0xfffe)
{
obj->RxTimeOut = true;
}
}
// Read the word
readWord = SPI_readEmu(obj->spiHandle);