2013-03-28 04:14 AM
Hello,
sorry for maybe stupid question, but I can't understand - how to make the frequency divider using STM32F4's timers? I mean how to divede the frequency of the external signal and output it from CPU? Tnanks. #stm32-timer2013-03-28 04:33 AM
This is far from being simple (any non-trivial use of the STM32 timers is, given their complexity).
First, you'd need to use one of the external clock modes, there are two of them. You'll find the details under ''Clock selection'' in the Timer chapter of manual. Then you need to run the timer as counter, perhaps setting the autoreload value (TIMx_ARR register) to the desired ''divider'' value. Then you need to output the ''divided'' clock. One of the options is to set one of the CC units to Compare, set half the ARR value to it, and set one of the PWM modes. JW2013-03-28 04:41 AM
What kind of frequencies are we talking about? What kind of division, fixed, range?
There are often much better solutions than the micro, and it's timers. The STM32 is endowed with some pretty lame integer dividers, so not the most flexible choice for clock generation.2013-03-28 06:21 AM
Hi CLive,
I'm talcking about frequencies 30-40MHz and not binary division - 3, 5, etc. All hardware solutions that I know, are more then one logic chip (2-3), cost is not an issue, but pcb space - yes.2013-03-28 06:49 AM
Better to include such (30-40MHz) spec w/in initial post. (and - Jan deserves some acknowledgement)
These are RF (HF band) frequencies - seems that an RF ''Mixer'' may be a better means to ''scale'' these - so they better ''fit'' MCU handling. As Clive states - these MCUs not ''best/brightest'' for this task - far simpler/smaller logic ICs may be better alternative...2013-03-28 06:59 AM
OK, its a pity :(
2013-03-28 07:18 AM
Have you tried a PLD? I think you could do it with a single chip rather than the 2-3 you're talking about.
2013-03-28 07:47 AM
Alex: ''its a pity :(''
Or not! MCU is much like race-horse - should not be used for ''all tasks.'' Might your need instead have been for a certain, ''frequency generation?'' While dividing down an existing frequency has appeal - the 30-40MHz is bit much for most MCUs. The MCU is quite good at generating various frequencies - often eased by use of an MCU Timer operated in PWM Mode. (enables fine control of both freq. and duty cycle) Too often - a vague ''specification'' produces limited or incorrect response...2013-03-28 09:27 AM
Perhaps I2S could be abused for this task, using the external clock input into PC9 and and MCK output onto PC6.
But I am afraid the smallest possible odd divider would be 5. JW2013-03-28 09:32 AM
Have you tried a PLD? I think you could do it with a single chip rather than the 2-3 you're talking about.
The logic in question would certainly fit in a PAL type device, perhaps there is some other logic or function you can mop up with a small programmable part? Other potential avenues are to clock the STM32F4 with an external source, or slave an SPI port into sending out a waveform/bitstream in a cyclic fashion. The resynchronizer on the front end of the STM32 timer pins might also add quite a lot of jitter to a 40 MHz signal.