Skip to content

Stuck with the (psc)prescaler calculations #369

Answered by adamgreig
NitinSaxenait asked this question in Q&A
Discussion options

You must be logged in to vote

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.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@NitinSaxenait
Comment options

Answer selected by NitinSaxenait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants