cancel
Showing results for 
Search instead for 
Did you mean: 

Fastest way to scan single adc channel

vindhyachal
Associate II
Posted on May 12, 2015 at 07:39

I am using STM32F205RBT6. System Freq = 120Mhz. APB2 freq = 60Mhz. ADCCLK = 30Mhz.

1. I have a input pulse of 300Khz.

2. Need to scan single an adc channel on each rising edge of pulse.

3. Have to store 21600 samples of 12 bit adc data i.e 43200 bytes of data.

4. Current requirement is 300Khz. But I think max freq may go upto 360Khz. But this is not current requirement.

What would be fastest way to store data in SRAM. Currently i am doing like this:

void main()

{

configure_all_peripherals();

confiure_adc_channel_3();      /* Tconv = 15 cycles = 0.5us */

configure_edge_int();

while(1)

{

data_cnt = 0;

while(data_cnt < 21600);

stop();

process_data();

}

}

void EXTI1_IRQHandler()

{

clear_isr_flag();

ADC1->CR2 |= ADC_CR2_SWSTART;

    while( !(ADC1->SR & ADC_FLAG_EOC) );

    adc_data[data_cnt++] = (u16_t)(ADC1->DR & 0x00000FFFU);

}
1 REPLY 1
raptorhal2
Lead
Posted on May 12, 2015 at 16:28

See Figure 28 in the F2 reference manual. Conversion can be started directly by EXTI_11 or 15. And DMA can stuff the results into a buffer until full with 21600 samples. Then you just need to check if the DMA counter = 0 to indicate done.

The DMA register is 16 bits. No need to mask off bits 16 to 31.

Cheers, Hal