cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103C8 Generating different frequencies and duty in same timer on different channels

Rajesh3
Associate

Hi,

I'm a beginner in embedded systems.

I'm trying out one thing that is I want to generate two different frequencies (100hz & 10hz) with both at 50% duty on TIMER 4 CH1 PWM Generation and TIMER 4 CH2 PWM Generation . Whether it is possible to generate different frequencies in same timer or is there any other method to generate it in STM32F103C8 blue pill kindly help me I'm stuck.

 

4 REPLIES 4

@Rajesh3 wrote:

STM32F103C8 blue phil


You mean Blue Pill ?

Note that a Blue Pill will (almost) certainly have a fake STM32 on it.

 


@Rajesh3 wrote:

I'm a beginner in embedded systems.


Save yourself a load of grief: get a genuine Nucleo board - which will include a genuine ST-Link.

eg, https://www.st.com/en/evaluation-tools/nucleo-f103rb.html

 

Cautionary tale on the perils of the Blue Pill (also, fake/clone ST-Links):

https://community.st.com/t5/stm32-mcus-products/blue-pill-stm32f1-board-gets-programmed-through-arduino-ide-but/m-p/667923

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
TDK
Guru

It is not possible to generate different frequencies on different channels of the same timer.

(If frequencies are 2x apart, and duty cycle is 50%, you can do this, but that's the only exception.)

 

If you feel a post has answered your question, please click "Accept as Solution".

One could perhaps use toggle mode, on a maximal counter, and then chase the CCx interrupts and CCRx points along that timeline.

Lot of balls to juggle, but could be considered.

One could perhaps use TIM+DMA+GPIO to drive a pattern buffer out some selective pins of a given bank via BSRR

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

> One could perhaps use toggle mode, on a maximal counter, and then chase the CCx interrupts and CCRx points along that timeline.

In this particular case - 10Hz and 100Hz - i.e. one of the frequencies is an integer multiple of the other and both are slow, so I'd run the 100Hz PWM "naturally", and the 10Hz by using "active on match/inactive on match" and changing CCRx in Update interrupt.

Probably not something that can be clicked in CubeMX; although I don't use Cube/CubeMX.

JW