Other Parts Discussed in Thread: HALCOGEN
Tool/software:
Hi (Jagadish),
I noticed that no matter what FIFO size of the ADC is configured (in HALCoGen), the generated code will always read the value of BUF0 (GxBUF[x].BUF0). For example, the adcGetData() function:
uint32 adcGetData(adcBASE_t *adc, uint32 group, adcData_t * data)
{
uint32 i;
uint32 buf;
uint32 mode;
uint32 index = (adc == adcREG1) ? 0U : 1U;
uint32 intcr_reg = adc->GxINTCR[group];
uint32 count = (intcr_reg >= 256U) ? s_adcFiFoSize[index][group] : (s_adcFiFoSize[index][group] - (uint32)(intcr_reg & 0xFFU));
adcData_t *ptr = data;
/* USER CODE BEGIN (16) */
/* USER CODE END */
mode = (adc->OPMODECR & ADC_12_BIT_MODE);
if(mode == ADC_12_BIT_MODE)
{
/** - Get conversion data and channel/pin id */
for (i = 0U; i < count; i++)
{
buf = adc->GxBUF[group].BUF0;
/*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
ptr->value = (uint16)(buf & 0xFFFU);
ptr->id = (uint32)((buf >> 16U) & 0x1FU);
/*SAFETYMCUSW 567 S MR:17.1,17.4 <APPROVED> "Pointer increment needed" */
ptr++;
}
}
else
{
/** - Get conversion data and channel/pin id */
for (i = 0U; i < count; i++)
{
buf = adc->GxBUF[group].BUF0;
/*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
ptr->value = (uint16)(buf & 0x3FFU);
ptr->id = (uint32)((buf >> 10U) & 0x1FU);
/*SAFETYMCUSW 567 S MR:17.1,17.4 <APPROVED> "Pointer increment needed" */
ptr++;
}
}
adc->GxINTFLG[group] = 9U;
/** @note The function adcInit has to be called before this function can be used.\n
* The user is responsible to initialize the message box.
*/
/* USER CODE BEGIN (17) */
/* USER CODE END */
return count;
}
And inside adcBase_t, it looks like this:
struct
{
uint32 BUF0; /**< 0x0090,0x00B0,0x00D0: Group 0-2 result buffer 1 register */
uint32 BUF1; /**< 0x0094,0x00B4,0x00D4: Group 0-2 result buffer 1 register */
uint32 BUF2; /**< 0x0098,0x00B8,0x00D8: Group 0-2 result buffer 2 register */
uint32 BUF3; /**< 0x009C,0x00BC,0x00DC: Group 0-2 result buffer 3 register */
uint32 BUF4; /**< 0x00A0,0x00C0,0x00E0: Group 0-2 result buffer 4 register */
uint32 BUF5; /**< 0x00A4,0x00C4,0x00E4: Group 0-2 result buffer 5 register */
uint32 BUF6; /**< 0x00A8,0x00C8,0x00E8: Group 0-2 result buffer 6 register */
uint32 BUF7; /**< 0x00AC,0x00CC,0x00EC: Group 0-2 result buffer 7 register */
} GxBUF[3U];
I am still wondering how the FIFO works under the hood, and more specifically:
1. Where are BUF1 to BUF7 used (what is their purpose)?
2. Does a read over one of that memory locations (for example, BUF0) will automatically rotate the hardware FIFO (move the tail)?
Thanks and regards,
Varban

