Skip to main content
Visitor II
October 26, 2023
Question

Multiple ADC Channels (using registers)

  • October 26, 2023
  • 1 reply
  • 1954 views

Hello all, I am currently working on a project in which I need to sample 5 ADC channels every 50 ms. As of now, I am trying to use TIM2's TRGO (interrupt triggered every 50 ms) to trigger the conversion of a regular sequence of 5 ADC channels (PA0 - PA4) and save these values by reading the ADC's data register in the ADC IRQ (triggered by the EOC interrupt flag). For some reason, I cannot figure out why the EOC interrupt is only triggered once, at the beginning of the program. If anyone could help, I would greatly appreciate it. 

 

I will post my code if needed (I am using the Keil uVision 5 IDE). Thanks in advance.

    This topic has been closed for replies.

    1 reply

    ST Employee
    October 26, 2023

    Hello Caden013, 

    Could you please show us your code so that we can look at it?

    Regards,
    Stassen

    caden013Author
    Visitor II
    October 26, 2023


    @Stassen.C wrote:

    Hello Caden013, 

    Could you please show us your code so that we can look at it?

    Regards,
    Stassen


    Yes, I will attach the ADC and Timer c files where I set their settings.

     

    Here is where I setup their corresponding clocks (in a different file):

     

    /*
    FUNCTION: clockSetup
    INPUTS: none
    OUTPUTS: none
    PURPOSE: To initialize the clocks for the peripherals
    */
    void clockSetup(void)
    {
    RCC->AHB2ENR |= RCC_AHB2ENR_GPIOAEN; // enable GPIOA clock
    RCC->AHB2ENR |= RCC_AHB2ENR_GPIOBEN; // enable GPIOB clock
    RCC->AHB2ENR |= RCC_AHB2ENR_ADCEN; // enable ADC clock
    RCC->APB1ENR1 |= RCC_APB1ENR1_TIM2EN; // enable clock for TIM2
    }