Part Number: TM4C1290NCPDT
Tool/software: TI-RTOS
Hello all,
I am having an issue where about 5% of the time, the SSI transfer I am initiating is not sending the full 6 bytes. Sometimes it will only send 2,3,4, or 5 bytes. I am looking at this on a scope to verify this. I will post my initialization and SSI code below. Now the interesting thing is that my check to ensure that all 6 byes were sent never fails (numFailed is always 0).
---------------------------------------------------------------------------------------------------------------
void setup_spi_for_onboard_com(void)
{
uint32_t lnTemp;
Hwi_Params SSI3_interruptParams;
Hwi_Handle SSI3_interrupt;
IntDisable(SSI_MODULE_INT);
SSIDisable(SSI_MODULE_BASE);
SysCtlPeripheralReset(SYSCTL_PERIPH_SSI3);
/*
* Register SSI3 interrupt handler.
* */
Hwi_Params_init(&SSI3_interruptParams);
SSI3_interruptParams.enableInt = false;
SSI3_interruptParams.instance->name = "SSI3_interrupt";
SSI3_interrupt = Hwi_create(71, SSIIntHandler, &SSI3_interruptParams, NULL);
//Configure SSI3
SSIConfigSetExpClk(SSI_MODULE_BASE, 120000000 /* SysCtlClockGet() */, SSI_FRF_MOTO_MODE_1, SSI_MODE_MASTER, 6250000, 8);
Hwi_enableInterrupt(71);
// Enable receive and TX End of Transmission interrupts
SSIIntEnable(SSI_MODULE_BASE, SSI_TXEOT | SSI_RXTO);
IntEnable(SSI_MODULE_INT);
SSIEnable(SSI_MODULE_BASE);
}
---------------------------------------------------------------------------------------------------------------
int32_t sendPackettoKinetis(PowerTecTx_Packet packet)
{
int32_t key, val;
int32_t numWritten = 0;
uint8_t i = 0;
key = LE_resource_lockwt(SPI_R, WAIT_FOREVER);
spiTxKinetisMsgBuffer[0] = (uint8_t)0xAA;//(packet.setPoint >> 8);
spiTxKinetisMsgBuffer[1] = (uint8_t)0xAA;//(packet.setPoint);
spiTxKinetisMsgBuffer[2] = (uint8_t)0xAA;//(packet.reserved >> 8);
spiTxKinetisMsgBuffer[3] = (uint8_t)0xAA;//(packet.reserved);
spiTxKinetisMsgBuffer[4] = (uint8_t)0xAA;//(packet.command);
spiTxKinetisMsgBuffer[5] = (uint8_t)0xAA;//packet.crc_checksum;
for(i=0; i<6; i++){
val = SSIDataPutNonBlocking(SSI_MODULE_BASE, (uint32_t )spiTxKinetisMsgBuffer[i]);
if (val>0){
numWritten += val;
spiBytesSent++;
}
}
while (SSIBusy(SSI_MODULE_BASE)){
LE_thread_sleep(100);
}
LE_resource_unlock(SPI_R, key);
if(numWritten !=6 ){
numFailed++;
return(0); //Error, should always do 6 bytes
}
numSent++;
return(1);
}