cancel
Showing results for 
Search instead for 
Did you mean: 

Injected channels and continuous sampling

beppe
Associate II
Posted on October 27, 2008 at 17:36

Injected channels and continuous sampling

3 REPLIES 3
beppe
Associate II
Posted on May 17, 2011 at 12:49

Hi all,

in my board i have several sensors and i need to sample them at different sampling rates. i was thinking i could use injeted channels sampled continuously and read the latest value from timers ISRs reading the appropriate injected channel's data register.

However, it seems I am not able to start a continuous sampling by ADC2 on the injected channels. here is a simplified version of the code:

Code:

ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;

ADC_InitStructure.ADC_ScanConvMode = DISABLE;

ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;

ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;

ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;

ADC_InitStructure.ADC_NbrOfChannel = 0;

ADC_Init(ADC2, &ADC_InitStructure);

ADC_InjectedSequencerLengthConfig(ADC2, 1);

ADC_InjectedChannelConfig(ADC2, ADC_Channel_8, 1, ADC_SampleTime_1Cycles5);

ADC_ExternalTrigInjectedConvConfig(ADC2, ADC_ExternalTrigInjecConv_None);

ADC_ExternalTrigInjectedConvCmd(ADC2, ENABLE);

ADC_ITConfig(ADC2, ADC_IT_JEOC, ENABLE);

ADC_Cmd(ADC2, ENABLE);

ADC_ResetCalibration(ADC2);

while(ADC_GetResetCalibrationStatus(ADC2));

ADC_StartCalibration(ADC2);

while(ADC_GetCalibrationStatus(ADC2));

ADC_SoftwareStartInjectedConvCmd(ADC2, ENABLE);

Any suggestions?

Thanks!

andreas2
Associate II
Posted on May 17, 2011 at 12:49

You don't need injected channels for that. Set up a regular continuous scan conversion of your channels, using DMA to transfer the results to an array. From your timer isrs, read the relevant index. There should be an example of the ADC stuff in the fwlib.

beppe
Associate II
Posted on May 17, 2011 at 12:49

Hi and thanks for your reply.

The problem is that i am already using the ADC1/DMA for sampling another sensor at a much higher rate.

The method you suggested will work, but i guess will cause a processing overhead i would like to avoid.

so since ADC1/DMA is used, and ADC2 cannot work with DMA, i was thinking to direct each sensor to injected channels (8 total on ADC1 and ADC2) and in timers ISRs get the values.

According to the ref manual it should be possible but i probably get something wrong in the init fuction i showed.

is this possible?

thanks!