cancel
Showing results for 
Search instead for 
Did you mean: 

EOC interrupt for ADC

orn
Associate II
Posted on October 22, 2012 at 16:42

 

 

The original post was too long to process during our migration. Please click on the attachment to read the original post.
This discussion is locked. Please start a new topic to ask your question.
14 REPLIES 14
orn
Associate II
Posted on October 23, 2012 at 16:09

the sampling rate there isn't an important requirement for my project,

I can change the field ADC_SampleTime_3Cycles without any problem

I do not understand when you write 3 x 100 x 2

I think you mean

3  are channels

100 are the samples

2??

these are the parameters you are referring to?

Posted on October 23, 2012 at 16:43

I do not understand when you write 3 x 100 x 2

You sample 3 channels

You want 100 samples (of the each 3)

You need the buffer 2 times as much so the HT (Half Transfer) will occur after 100 samples, and TC (Transfer complete) will occur after 200

The idea with a circular transfer with HT/TC interrupts is you ping-pong between two copies which you can process without the DMA over writing each other.

Such a buffer would contain 600 entries, you'd process/digest 300 (100 x 3) at each interrupt.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
orn
Associate II
Posted on October 23, 2012 at 18:45

a thousand times thanks!

I made the changes you suggested and I think I have made them in the right way please correct me if I made mistakes,

void DMA2_Stream0_IRQHandler(void)
{
/* Test on DMA Stream Transfer Complete interrupt */
if (DMA_GetITStatus(DMA2_Stream0, DMA_IT_TCIF0))
{
/* Clear DMA Stream Transfer Complete interrupt pending bit */ 
DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_TCIF0);
printf(''

 example of the process - half of sample buffer 

'');
for(i=300;i<600;i=i+3){ 
printf(''s %d - '',ADC3ConvertedValue[i]*K_adc/0xFFF);
printf(''s %d -'',ADC3ConvertedValue[i+1]*K_adc/0xFFF);
printf(''s %d -'',ADC3ConvertedValue[i+2]*K_adc/0xFFF);
printf(''
'');
}
printf(''s %d 
'',i);
}
/* Test on DMA Stream Half Transfer interrupt */
if (DMA_GetITStatus(DMA2_Stream0, DMA_IT_HTIF0))
{
/* Clear DMA Stream Half Transfer interrupt pending bit */
DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_HTIF0);
printf(''

 example of the process - first half of sample buffer 

'');
for(i=0;i<300;i=i+3){
printf(''f %d - '',ADC3ConvertedValue[i]*K_adc/0xFFF);
printf(''f %d -'',ADC3ConvertedValue[i+1]*K_adc/0xFFF);
printf(''f %d -'',ADC3ConvertedValue[i+2]*K_adc/0xFFF);
printf(''
'');
}
printf(''f %d 
'',i);
}

DMA_InitStructure.DMA_BufferSize = 600; output seems correct :)
Posted on October 24, 2012 at 18:08

Generally Ok, I wouldn't be using printf() under interrupt, and would use a 0x1000 division rather than 0xFFF.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
orn
Associate II
Posted on October 24, 2012 at 21:33

endless thanks! your suggestions are very valuable :)