Skip to main content
Explorer
June 25, 2025
Question

Stm32f407vgtx Timer Funtionality

  • June 25, 2025
  • 2 replies
  • 296 views

Hi 

I am facing one issue I am trying to run Timer2 and as soon I have enable the by setting CR1 register bit CEN, My all flags in SR is getting set even I have enabled only(UIE) so my UIF flag bit in SR register must set but it is setting all (CC4IF CC3IF CC2IF CC1IF) .

Can you help me to understand is it normal or why it was happened?

B.R

Ashish

    This topic has been closed for replies.

    2 replies

    Super User
    June 25, 2025

    The flags get set regardless of whether or not the interrupt for that flag is enabled.

    CCxIF flags will be set if CCRx = 0 and the counter is started with the channel in output mode (default). If the interrupt is not enabled, it will not fire as a result of these flags. This is the expected behavior and no action is required.

    Ash1Author
    Explorer
    June 26, 2025

    image.pngimage.pngimage.pngHi 

    Thansks for your reply .

    I have another doubt which I am facing I am running timer1 at 1MHZ clock frequency so When I loaded value in ARR with (999) which represents me 1ms delay(Which is fine I am able to generate 1ms delay).

    But when I am loading 999 value in CCR1 register instead of in ARR register (Note : I am getting delay of 500 microseconds and total wave is 1ms so I want to know Why  is it working like this can you help me with understanding.)

    NOTE: I am working with downcounter and in my ARR register value is 0xFFFF.

    I have attached screenshots of registers for better understanding.

    B.R

    Ashish

    Super User
    June 26, 2025

    The Reference Manual goes into detail into how to timer operates.

    Why are you loading 500 in CCR1? What is your goal here?

    The screenshots show CCR1 is not 500.