cancel
Showing results for 
Search instead for 
Did you mean: 

clock frequency calculations

Divyanshu
Associate II

Hi,

I am going to use internal osc for generating a frequency of signal 36khz.

  1. Do i need any external circuitry for it ..?
  2. For selection of 8Mhz frequency as clock can it be done in cube mx only and generate a source code form there...?
  3. Selection of prescaler for 8MHZ frequency to get signal of 36khz.

1 ACCEPTED SOLUTION

Accepted Solutions
S.Ma
Principal

Which STM32 is being used?

Most of the time it's a question of clock tolerances which is the real parameter to look after.

View solution in original post

5 REPLIES 5
S.Ma
Principal

Which STM32 is being used?

Most of the time it's a question of clock tolerances which is the real parameter to look after.

STM32F030F4P6

APB timer is being used

All this stuff is basic division. You have integer dividers, and you may or may not need a prescaler depending on how low the frequencies are.

The Prescaler and Period settings on the F0 will all be limited to 16-bit

CLOCKOUT = (CLOCKIN / Q) / P

Where

Prescaler = Q - 1

Period = P - 1

To get 36 KHz, you'd probably want to use 9 MHz rather than 8 MHz

ie 9,000,000 / 36,000 = 250 <- an integer

Prescaler = 0, Period = 249

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Piranha
Chief II

8'000'000 : 36'000 = 2000 : 9

Your MCU allows / 2 * 9 to get 36 MHz and then / 1000 in timer to get 36 kHz. But if it's remote IR protocol, then it doesn't need such an exact frequency. For example You can run MCU at 48 MHz and do / 1333 in timer to get 36'009 Hz frequency, which is more than enough precise.