This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I am working on SPI Master with 28335 controller and SPI slave with same controller. Master is in polling and Slave is in interrupt mode.
Following is the code for Master.
bool spidrvA_ReceiveCmdResponse_vd(uint16_t responseLen_u16)
{
uint16_t index_u16 =0;
uint16_t recvLength_u16 = 0;
uint16_t dummyData_u16 = SPI_DUMMY_WORD;
recvLength_u16 = responseLen_u16;
for(index_u16=0;index_u16<recvLength_u16-1;index_u16++)
{
SpiaRegs.SPITXBUF = dummyData_u16;
while(SpiaRegs.SPISTS.bit.INT_FLAG != 1); // 9.2 us
rxdata_u16a[index_u16] = SpiaRegs.SPIRXBUF;
delay_vd(1); //11.2 us
}
return 1;
}
In the above function there is function call delay_vd(1), If this function is commented, then Master is not able to receive the data.
while(SpiaRegs.SPISTS.bit.INT_FLAG != 1); is takeing 9.2 us for changing the flag status. delay_vd(1); is taking 11.2us
As per the datasheet delay function is not required, But in pratical If the delay 11.2 us is removed, then data is corrupting.
Following is the slave code.
void spi_ReceiverA_Isr_vd(void)
{
SpiaRegs.SPITXBUF = msgTxPtrSPIA_u16a[spiTxIndex_u16];
spiTxIndex_u16++;
if(spiTxIndex_u16 == txlen_u16)
{
//data transmission completed.
}
EALLOW;
PieCtrlRegs.PIEACK.all|=PIEACK_GROUP6; // Issue PIE ACK
EDIS;
}
SPI is configured in 10Mbps speed, 512 bytes of data will be requested by master from slave on very 75ms.
Please give suggestion for changes.