I'm facing an issue with the STM1 timer. I've configured two counters: Counter_1 running at 1ms for STM0 (CH0) and Counter_2 running at 1us for STM1 (CH0). The STM0 counter works fine, but STM1 is not updating as expected. Instead of updating every 1us, it updates every 15-25s.
Configuration Details:
Clock for both STM0 and STM1: 133.33333 MHz Prescaler (PSC) for both: 1 Compare values: 0x208D5 for 1ms (STM0) and 0x85 for 1us (STM1) Interrupt priority: 4 for STM0, 5 for STM1
According to the timer's PSC and clock frequency, it is theoretically possible to achieve 1us, if you doubt the reason for performance, you can try to set STM1 larger time, such as 100us or 2ms.
I will try to look at the code for you and find the problem. In addition, The second problem is that I suggest that you do not apply STM0 and only use STM1 to check whether STM1 itself is configured incorrectly. If STM1 works well alone, you should focus on finding configuration problems between the two STMS when they are used.
Are you using STM0 and STM1 in debug mode, and if so, check to see if the value of CNT reaches the comparison value to enter the interrupt. Also, try setting Freeze mode to FALSE.
Yes, I am. The CNT value for STM0 (1ms) continuously updates every 1ms, upon reaching CMP value (IRQ assertion is happening properly). But for STM1 (1us), the CMP value only updates after CNT value falls over from FFFFFFFF to 00000000 and then matches the CMP value (IRQ assertion is improper). So, it takes 10-15s for my counter to update its value.
Yes, I'm doing that. My doubt now, is whether a time period of 1us is feasible. This means 1000000 interrupts per second. So, it might lead to a runtime problem. Could you shed some light on this?
According to the timer's PSC and clock frequency, it is theoretically possible to achieve 1us, if you doubt the reason for performance, you can try to set STM1 larger time, such as 100us or 2ms.