I have a working software trigger adc project and am now hoping to see how I can add dma to the code. I have had a look at How to use RT1052 ADC-ETC function to convert ADC1 and ADC2 but could not figure out how this could work with software trigger. Does anyone know? Below is what I have at the moment.
extern "C"
void ADC1_IRQHandle()
{
g_value = ADC_GetChannelConversionvalue(ADC1, 0U);
g_flag.Set();
}
void Initialise() {
adc_config_t adcConfig;
ADC_GetDefaultConfig(&adcConfig);
ADC_Init(ADC1, &adcConfig);
ADC_SetHardwareAverageConfig(ADC1, kADC_HardwareAverageCount16);
NVIC_SetPriority(AdcIrq, 3);
EnableIRQ(AdcIrq);
}
bool Read(const uint32_t channel, uint32& value) {
const uint32_t channelGroup = 0U; // Only channel group zero can be used for software trigger
adc_channel_config_t channelConfig = { channel, true }; // enable interrupt
g_flag.Reset();
ADC_SetChannelConfig(ADC1, channelGroup, &channelConfig); // trigger in software
if (!g_flag.Wait(50))
{
return false;
}
value = g_value;
return true;
}
Hi @DCheung ,
To trig ADC by ADC register, you can write ADC_HC0 register, other ADC-HCx don't support software trig.
To trig ADC by ETC register, you can set ETC->TRIGx_CTRL.SW_TRIG bit.
To trig ADC by DMA, you can have DMA write a new value to ADC_HC0.
ETC hardware trig is from XBAR, you also can have some signal to TRIG ADC_ETC by XBAR.
Regards,
Jing