2021-10-08 11:45 PM
Hello,
I am using Nucleo-H743ZI ,I am using timer1 to trigger ADC.
My APB1 clock frequency is 240MHz and my ARR register is 240 of timer 1. So my sampling rate of ADC should be 1Msamples/sec. To check it I am toggling a pin whenever ADC conversion complete is done.
Instead of 1Msamples/sec I am getting around 250Ksamples/sec what might be the issue.
For low PWM frequency the relation (TIMER1_freq=APB1_frequency/ARR) is working fine as I decrease ARR my PWM output is not following above formulae.
Can anyone help me out what might be the issue?
Solved! Go to Solution.
2021-10-09 08:20 AM
2021-10-09 07:25 AM
Your processor does not have infinite power. Trying to call an interrupt at 1 MHz is overloading the system and it can't keep up.
> TIMER1_freq=APB1_frequency/ARR
The equation, at least in how it relates to ARR, is actually:
> TIMER1_freq = APB1_frequency / (ARR + 1)
2021-10-09 07:45 AM
Then how should I trigger ADC to get 1 Mega samples/sec
2021-10-09 08:05 AM
2021-10-09 08:20 AM
2021-10-16 05:35 AM
I didn't get you what you meant to say is that "Instead of timers to trigger adc use dma without cpu intervation" so that I can achievw high sample rate. Am I right correct me If I am wrong.
2021-10-16 08:11 AM
I'm not sure what you're asking.
Use a timer to trigger ADC conversions on the TRGO event. Use DMA to transfer that information directly to memory. The HAL_ADC_Start_DMA will be used to start the process.
2021-10-16 08:15 AM
When dma runs in circular mode, you have array in memory which is contantly overwritten by the new data from ADC. This process does need any function calls from main loop and runs endlessly after ADC is started incircular DMA mode. Now, if you enable DMA half complete and complete interrupts, you have information about which part of memory just have ben overwritten. At high sampling rates you must act fast, either perform some light-weight computstions, or copy recently filled array halves to a safe memory location for further processing. If you perform some heavy processing inside interrupt data may be overwritten before even being processed. In those interrupts you can call memcpy or use mem2mem tranfer. Enable circular DMA mode, call simgle function to start ADC in DMA mode and insert code for HAL_ADC_ConvHalfCpltCallback and HAL_ADC_ConvCpltCallback callback functions in main.c
2021-10-16 08:17 AM
@TDK Using this technique will I be able to achieve 1Msamp/sec data rate?
2021-10-16 08:19 AM