2020-09-14 09:19 PM
Hi, I'm using adc single channel with interrupt. the sample time is set as 56 cycles, and the adc clock is (108MHz/4=27MHz). So the sample rate is 27MHz/(56+12)=397KHz. I also using DAC to generate a sinewave with the frequency of 1KHz. If what I calculate is correct, I will get 2.5 periods of sinewave when I sample 1000 points. however, I plot the data in matlab, I get more than 4 periods. I am confused which part is wrong.
thanks
2020-09-14 10:32 PM
Which STM32?
Switch on compiler optimization.
Toggle a pin at ADC ISR entry and exit, and observe on oscilloscope/LA, to see its execution time.
JW
2020-09-15 05:31 AM
Calling a HAL ADC conversion complete interrupt every 68 cycles (397KHz) is unlikely to work. Use DMA or reduce the sample rate or optimize the ISR by eliminating HAL.
2020-09-15 12:49 PM
If I understood correctly, AHB or APB respective to ADC is 108MHz, so it's 4x or 8x that, i.e. 272 or 544 cycles. Maybe that is marginally viable if optimization is switched on.
JW