Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN
Hi,
I am using the PWMB event to trigger ADC readings, and I am having some question/issues.
The configuration I am using is the following (ADC/PWM example from HalCoGen):



I wrote this simple script to check the order of the data inside the data array after using the adcGetData function.
int main(void)
{
/* USER CODE BEGIN (3) */
/* enable irq interrupt in */
_enable_IRQ_interrupt_();
adcInit();
etpwmInit();
adcStartConversion(adcREG1, adcGROUP0);
etpwmStartTBCLK();
while(1)
{
adcData_t data[16];
for(volatile uint8_t ii; ii < 16; ii++)
{
data[ii].id = 0;
data[ii].value = 0;
}
uint32 count;
uint16 cmpA;
count = adcGetData(adcREG1, adcGROUP0, data);
volatile uint8_t tmp_brkpnt = 0;
volatile uint32_t id = data[0].id;
if(15 == id || 14 == id || 13 == id)
{
tmp_brkpnt = 1;
}
}
while(1);
/* USER CODE END */
return 0;
}
The data order inside the array seems to be inconsistent, as you can see on the following pictures:


Is the order not supposed to stay the same ? And is it normal to have two ADC readings of the same channel in a row ?
Also, it seems like I have to read the ADC buffer in order to get ADC readings. Indeed, when I am stopping the program in debug mode, if I change the input voltage of the pin, I need to read the ADC buffer twice in order to see the updated voltage.
Thank you !