Part Number:TMS320F28379S
Hi, Champs,
My customer is using F28379S to implement Tamagawa encoder and there's a question on getting the data correctly.
As you know, below codes used to read position are placed in while(1), while in real application, customer hopes to read it in the current loop interrupt which is 16kHz@62.5us.
Problem is that, when those codes are moved to current loop where has higher interrupt priority, the SPI interrupt used to receive data will be not serviced correctly due to lower interrupt priority. Do we have a solution to support getting position feedback in a faster way?
With this background, we thought about several approaches:
a. Add a condition to run below codes as a function like below:
if(tformatData.dataReady == 1)
{
CLB_Get_TamagawaAbsEncoder(); // This function contains below codes
}
But it takes more than 70us to execute, which is not acceptable in customer system.
Can we verify if the 70us is resulted by the SPI ISR or the " while (tformatData.dataReady != 1) {}" statement?
b. We can try CLA to run to SPI interrupt and tformat library based on CLB, and we know CLA can support SPI but can it support running CLB?
c. We can also use DMA to transfer data from SPI to a RAM buffer with FIFO support, but we still need to do CRC check and CLB logic, where can we find a flag to do that polling?
retval2 = PM_tformat_setupCommand(DATAID3, 0, 0, 0);
PM_tformat_startOperation();
while (tformatData.dataReady != 1) {}
retval2 = PM_tformat_receiveData(DATAID3);
crcResult = PM_tformat_getCRC(0, 80, 8, (uint16_t *)&tformatData.rxPkts, tformatCRCtable, 10);
crcResult = crcResult ^ (0xFF);
if(!CheckCRC(crcResult,tformatData.crc))
{
ESTOP0;
}
//Invert the received bit sequence for position and turns for actual data
position = ((__flip32((uint32_t) tformatData.dataField0) >> 24 ) & 0xFF)|
((__flip32((uint32_t) tformatData.dataField1) >> 16 ) & 0xFF00)|
((__flip32((uint32_t) tformatData.dataField2) >> 8 ) & 0xFF0000);
turns = ((__flip32((uint32_t) tformatData.dataField4) >> 24 ) & 0xFF)|
((__flip32((uint32_t) tformatData.dataField5) >> 16 ) & 0xFF00)|
((__flip32((uint32_t) tformatData.dataField6) >> 8 ) & 0xFF0000);
Best Regards,
Ricky Zhang