Stuck with the (psc)prescaler calculations #369
-
Hi, I am new to Embedded and Rust too. I am working on the stm32f3 discovery board and completed the 8 chapters. Now I am working with the chapter clock & timers. I read the whole chapter, registers we are using, and how we are changing our way to use delay. I have searched about the counters and Prescaler(The purpose of the Prescaler is to allow the timer to be clocked at the rate a user desires).
I'm going to let you figure out the value of the prescaler, psc. Remember that the frequency of the counter is apb1 / (psc + 1) and that apb1 is 8 MHz. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It sounds like you've almost got it! The timer is driven at 8MHz by the core, which means each "tick" (in other words, every count it makes) takes 1/8000000=125 nanoseconds. But, we'd like it to count in milliseconds instead, which means it needs to run at 1kHz. Since the 8MHz input is fixed, we must use the prescaler to divide the incoming 8MHz frequency down to the 1kHz frequency we'd like it to run at. The output frequency is freq_out = APB1 / (PSC + 1), and APB1 is 8MHz, so we need to solve the equation 1000 = 8000000 / (PSC + 1) to find the value for PSC, 7999. |
Beta Was this translation helpful? Give feedback.
It sounds like you've almost got it!
The timer is driven at 8MHz by the core, which means each "tick" (in other words, every count it makes) takes 1/8000000=125 nanoseconds. But, we'd like it to count in milliseconds instead, which means it needs to run at 1kHz.
Since the 8MHz input is fixed, we must use the prescaler to divide the incoming 8MHz frequency down to the 1kHz frequency we'd like it to run at. The output frequency is freq_out = APB1 / (PSC + 1), and APB1 is 8MHz, so we need to solve the equation 1000 = 8000000 / (PSC + 1) to find the value for PSC, 7999.