Hi,
My software is working in K312, RTD version is 3.0.1 P01, chain type is normal, conversion mode is one-short.
Image of my reading ADC function is like:
Hi @mym,
The input channels are muxed into the ADC, so you need to set the ADCx_Rn register to the channel number you want to convert, run the conversion, read the results and then set the other ADCx_Rn in that ADC to the next channel to be converted. The next conversion can then be triggered. You have to tell each conversion the input channel it is to convert.
You can simply start a SW triggered normal conversion, and wait for the notification to be triggered and read the data:
void AdcEndOfChainNotif(void)
{
notif_triggered = TRUE;
data_bandgap = Adc_Sar_Ip_GetConvData(ADCHWUNIT_0_INSTANCE, ADC_SAR_USED_CH_BANDGAP);
data_POT_0 = Adc_Sar_Ip_GetConvData(ADCHWUNIT_0_INSTANCE, ADC_SAR_USED_CH_POT_0);
/* Process the result to get the value in volts */
data_bandgap_volt = ((float) data_bandgap / adcMax) * (ADC_VREFH - ADC_VREFL);
data_POT_0_volt = ((float) data_POT_0 / adcMax) * (ADC_VREFH - ADC_VREFL);
__asm volatile ("nop");
}}
int main (void)
{
...
/* Start a SW triggered normal conversion on ADC_SAR */
Adc_Sar_Ip_StartConversion(ADCHWUNIT_0_INSTANCE, ADC_SAR_IP_CONV_CHAIN_NORMAL);
/* Wait for the notification to be triggered and read the data */
while (notif_triggered != TRUE)
{
__asm volatile ("nop");
}
notif_triggered = FALSE;
...
}
Take a look into these community examples:
The first example uses the PIT trigger to trigger BCTU conversion list to perform conversions on different ADC1 channels.
Best regards,
Julián
Hi Julián
Thank you for your answer.
I still have some doubts.
In K3, REG NCMR seems used to select channels I want to convert?
1.Select channel by sdk function Adc_Sar_SetNormalChain
2.Start convert instance.
3.Read convert result and Confirm the valid flag in result.
4.Keep Reading until valid flag became 1.
5.Use data after valid flag became 1.
Is this a feasible usage?
Thanks
reguards
YM