2012-10-22 07:42 AM
2012-10-23 07:09 AM
the sampling rate there isn't an important requirement for my project,
I can change the field ADC_SampleTime_3Cycles without any problemI do not understand when you write 3 x 100 x 2I think you mean3 are channels100 are the samples2??these are the parameters you are referring to?2012-10-23 07:43 AM
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.2012-10-23 09:45 AM
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 :)
2012-10-24 09:08 AM
Generally Ok, I wouldn't be using printf() under interrupt, and would use a 0x1000 division rather than 0xFFF.
2012-10-24 12:33 PM
endless thanks! your suggestions are very valuable :)