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.

TMS570LC4357: HALCoGen MibSPI transfergroup1 does not end SPI transaction and keeps sending data(zeroes) indefinitely.

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

Hello,

We'd like to use multiple Transfer Groups with Hercules MCU, but we've run in to issues with second TG.

Currently tested approach is using two TGs (TG0 and TG1) with same configuration 128 words.

If the TG0 is used the transfer is properly terminated after 128words transferred.

If the same data is transferred using TG1 the sent data aren't the same as the data expected(mostly zeroes in the beginning) and continues as infinite loop of zeroes sent from MOSI an the code stays in loop checking if the transfer was done. 

while(!(mibspiIsTransferComplete(mibspiREG2, 1)));

In debug session I've noticed unexpected behavior in mibspiSetData function generated from HalCoGen.

void mibspiSetData(mibspiBASE_t *mibspi, uint32 group, uint16 * data)
{
/* USER CODE BEGIN (12) */
/* USER CODE END */

    mibspiRAM_t *ram    = mibspi == mibspiREG1 ? mibspiRAM1 : 
	                     (mibspi == mibspiREG2 ? mibspiRAM2 : 
						 (mibspi == mibspiREG3 ? mibspiRAM3 : 
						 (mibspi == mibspiREG4 ? mibspiRAM4 : mibspiRAM5)));
    uint32 start  = (mibspi->TGCTRL[group] >> 8U) & 0xFFU;
    uint32 end    = (group == 7U) ? (((mibspi->LTGPEND & 0x00007F00U) >> 8U) + 1U) : ((mibspi->TGCTRL[group+1U] >> 8U) & 0xFFU);

    if (end == 0U) {end = 128U;}

    while (start < end)
    {
    /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
        ram->tx[start].data = *data;
        data++;
        start++;
    }
/* USER CODE BEGIN (13) */
/* USER CODE END */
}

The "start" and "end" variables for TG1 are equal 128 and 254 which means in this part "ram->tx[start].data = *data;"  it writes data to some unallocated space.

The "start" and "end" for TG0 are equal 0 and 128. which is expected range for  "ram->tx[start].data = *data;"

Could it be some bug from HalCoGen generator, some misconfiguration or misinterpretation?

Thank you

Jiri Petrovsky