Skip to main content
orn
Associate III
October 22, 2012
Question

EOC interrupt for ADC

  • October 22, 2012
  • 14 replies
  • 2985 views
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 topic has been closed for replies.

    14 replies

    Tesla DeLorean
    Guru
    October 23, 2012
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    orn
    ornAuthor
    Associate III
    October 23, 2012
    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 :)
    Tesla DeLorean
    Guru
    October 24, 2012
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    orn
    ornAuthor
    Associate III
    October 24, 2012
    Posted on October 24, 2012 at 21:33

    endless thanks! your suggestions are very valuable :)