Part Number:DRV8301
As I am working on communication with a different controller over SPI I'm having troubles with data integrity.
The motor controller communicates by default on SPIA (with the drv8301Boost on J1)
I have setup the SPIB channel for the communication with a TI infineon kit with my controller as a slave.
The code is based on lab 13c of motorware.
I wrote an RX interrupt routine which reads out a 4 words FIFO buffer.
I tried reading it out word by word or 2 or 4 words at the time.
The routine does this
interrupt void spiFIFORX_ISR(void)
{
for (loop >=0 ; loop< 1; loop++){
data[test123] = SPI_read(halHandle->spiBHandle);
test123++;
}
if (test123 >= 40){
test123 = 0;
}
// else{
// //do nothing
// }
rx_cnt++;
loop =0;
SPI_clearRxFifoInt(halHandle->spiBHandle);
SPI_clearRxFifoOvf(halHandle->spiBHandle);
PIE_clearInt(halHandle->pieHandle,PIE_GroupNumber_6);
}As you can see i read out 40 words in this case one at the time from a 4 word FIFO buffer at a speed of 1megabaut.
At the receiver side i send all 40 words with the push of 1 button/
When working correctly I get 40 interrupts and my data gets filled as planned.
The issue is when i repeat the send (and increasing my speed in pushing the button) i see the data integrity failing.
I than get 39 interrupts in like 10% of the cases.
When I set the motor controller to be active (with the run identify flag) it gets even worse.
Than every time i send data i miss like 5-10 interrupts.
I'm my interpretation that means the controller is busy with different interrupts with a higher priority I would say (?)
Any idea how i can maintain my data integrity 100% of the time? Because this communication line is very critical for the system I am developing.
for reference this is my SPIB setup.
void HAL_setupSpiB(HAL_Handle handle)
{
HAL_Obj *obj = (HAL_Obj *)handle;
SPI_reset(obj->spiBHandle);
SPI_resetRxFifo(obj->spiBHandle);
SPI_resetTxFifo(obj->spiBHandle);
SPI_disableLoopBack(obj->spiBHandle);
SPI_enableRxFifo(obj->spiBHandle);
SPI_enableTxFifo(obj->spiBHandle);
SPI_enableRxFifoInt(obj->spiBHandle);
SPI_enableTxFifoInt(obj->spiBHandle);
SPI_enableTxFifoEnh(obj->spiBHandle);
SPI_setRxFifoIntLevel(obj->spiBHandle, SPI_FifoLevel_4_Words);
SPI_setTxFifoIntLevel(obj->spiBHandle, SPI_FifoLevel_4_Words);
//SPI_setBaudRate(obj->spiaHandle, SPI_BaudRate_1_MBaud);
SPI_setCharLength(obj->spiBHandle, SPI_CharLength_16_Bits);
SPI_setClkPhase(obj->spiBHandle, SPI_ClkPhase_Normal);
SPI_setClkPolarity(obj->spiBHandle, SPI_ClkPolarity_OutputRisingEdge_InputFallingEdge);
SPI_setMode(obj->spiBHandle, SPI_Mode_Slave);
//SPI_setPriority(obj->spiBHandle, SPI_Priority_AfterRxRxSeq);
SPI_setTxDelay(obj->spiBHandle,0x0000);
SPI_enableInt(obj->spiBHandle);
SPI_enable(obj->spiBHandle);
PIE_enableInt(obj->pieHandle, PIE_GroupNumber_6, PIE_InterruptSource_SPIBRX);
PIE_enableInt(obj->pieHandle, PIE_GroupNumber_6, PIE_InterruptSource_SPIBTX);
CPU_enableInt(obj->cpuHandle, CPU_IntNumber_6); // enable SCI CPU interrupt
return;
} // end of HAL_setupSpiB() functiongreetings,
Alain









