2023-10-26 07:26 AM
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.
2023-10-26 07:40 AM
Hello Caden013,
Could you please show us your code so that we can look at it?
Regards,
Stassen
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-10-26 07:42 AM - edited 2023-10-26 07:44 AM
Yes, I will attach the ADC and Timer c files where I set their settings.
@Stassen.C wrote:Hello Caden013,
Could you please show us your code so that we can look at it?
Regards,
Stassen
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
}