cancel
Showing results for 
Search instead for 
Did you mean: 

While(1) Not Executing

BitCurious
Associate II

I am using STM32 with the following peripherals:

  • TIM7 for frequency generation
  • ADC with DMA
  • DAC with DMA
  • TIM Interrupt (TIM_IT)

My setup:

  • Clock: 150 MHz
  • Prescaler (PSC:( 3-1
  • Auto-reload register (ARR:( 13-1
  • 128 samples for DAC to generate a 30 kHz signal

When using these settings, the ADC half-complete and complete callbacks are triggered correctly, meaning ADC DMA is working. However, nothing seems to happen in the while(1) loop in main().

What do you think could be causing this?

Could it be related to TIM7 interrupt priority, DMA behavior, or CPU being blocked?
Is the DMA transfer taking over completely, preventing execution in while(1)?
Any insights or suggestions would be greatly appreciated!

2 REPLIES 2
SofLit
ST Employee

Hello,

May be due to the CPU load due to the interrupt timing rate and the CPU was not able to get a time slot to reach the while loop. As soon as it exits the interrupt it returns in it again. If you disable the interrupt do you reach the while(1)?

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.
PS:
1 - This is NOT an online support (https://ols.st.com) but a collaborative space.
2 - Please be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help.
KnarfB
Principal III

30 kHz *  half-complete and complete callbacks = 60k interrupts/s ?

That's alot, especially when using HAL. Try lowering the freq. generously by increasing PSC until "something happens" in the main loop. You may use the DWT cycle counter to estimate the length your code spends in the interrupts or use some logic analyzer for that.

 Solved: How do you measure the execution CPU cycles for a ... - STMicroelectronics Community

hth

KnarfB