Hi,all ,I set the Length to be 128 ,then the MibSPI pin of data can't send out bit ,but the clock of MibSPI still work ,If I change the Length to 127,then MibSPI work correctly,I want to know why ?
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.
Hi,all ,I set the Length to be 128 ,then the MibSPI pin of data can't send out bit ,but the clock of MibSPI still work ,If I change the Length to 127,then MibSPI work correctly,I want to know why ?
Hi Jiaming,
Can you please identify the device and version of HalCoGen on which you are experiencing this issue?
Thanks,
Paul B.
Thanks Jiaming. I've assigned this question to one of our experts who will get back to you.
Hi Jiaming,
Its a minor Bug in HALCoGen. HALCoGen drivers are currently designed to support only 127 Buffers. The issue is with mibspiSetData and mibspiGetData API's. We are fixing this in upcoming release.
Workaround:
Using the user code you can replace the API definitions as below, so that it is not affected when you are generating the code again.
/** @fn void mibspiSetData(mibspiBASE_t *mibspi, uint32 group, uint16 * data)
* @brief Set Buffer Data
* @param[in] mibspi - Spi module base address
* @param[in] group - Transfer group (0..7)
* @param[in] data - new data for transfer group
*
* This function updates the data for the specified transfer group,
* the length of the data must match the length of the transfer group.
*/
/* SourceId : MIBSPI_SourceId_003 */
/* DesignId : MIBSPI_DesignId_003 */
/* Requirements : HL_SR155 */
void mibspiSetData(mibspiBASE_t *mibspi, uint32 group, uint16 * data)
{
/* USER CODE BEGIN (6) */
#if 0
/* USER CODE END */
mibspiRAM_t *ram = mibspi == mibspiREG1 ? mibspiRAM1 : (mibspi == mibspiREG3 ? mibspiRAM3 : 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 < start) {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 (7) */
#endif
mibspiRAM_t *ram = mibspi == mibspiREG1 ? mibspiRAM1 : (mibspi == mibspiREG3 ? mibspiRAM3 : 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 == 0) {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 END */
}
/** @fn void mibspiGetData(mibspiBASE_t *mibspi, uint32 group, uint16 * data)
* @brief Retrieves Buffer Data from receive buffer
* @param[in] mibspi - Spi module base address
* @param[in] group - Transfer group (0..7)
* @param[out] data - pointer to data array
*
* @return error flags from data buffer, if there was a receive error on
* one of the buffers this will be reflected in the return value.
*
* This function transfers the data from the specified transfer group receive
* buffers to the data array, the length of the data must match the length
* of the transfer group.
*/
/* SourceId : MIBSPI_SourceId_004 */
/* DesignId : MIBSPI_DesignId_004 */
/* Requirements : HL_SR156 */
uint32 mibspiGetData(mibspiBASE_t *mibspi, uint32 group, uint16 * data)
{
/* USER CODE BEGIN (8) */
#if 0
/* USER CODE END */
mibspiRAM_t *ram = mibspi == mibspiREG1 ? mibspiRAM1 : (mibspi == mibspiREG3 ? mibspiRAM3 : mibspiRAM5);
uint32 start = (mibspi->TGCTRL[group] >> 8U) & 0xFFU;
uint32 end = group == 7U ? (((mibspi->LTGPEND & 0x00007F00U) >> 8U) + 1U) : ((mibspi->TGCTRL[group+1U] >> 8U) & 0xFFU);
uint32 mibspiFlags = 0U;
if (end < start) {end = 128U;}
while (start < end)
{
mibspiFlags |= ram->rx[start].flags;
/*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
*data = ram->rx[start].data;
data++;
start++;
}
/* USER CODE BEGIN (9) */
#endif
mibspiRAM_t *ram = mibspi == mibspiREG1 ? mibspiRAM1 : (mibspi == mibspiREG3 ? mibspiRAM3 : mibspiRAM5);
uint32 start = (mibspi->TGCTRL[group] >> 8U) & 0xFFU;
uint32 end = group == 7U ? (((mibspi->LTGPEND & 0x00007F00U) >> 8U) + 1U) : ((mibspi->TGCTRL[group+1U] >> 8U) & 0xFFU);
uint32 mibspiFlags = 0U;
if (end == 0) {end = 128U;}
while (start < end)
{
mibspiFlags |= ram->rx[start].flags;
/*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
*data = ram->rx[start].data;
data++;
start++;
}
/* USER CODE END */
return (mibspiFlags >> 8U) & 0x5FU;
}