Skip to main content
Explorer
August 6, 2024
Question

Blue Pill STM32F103C8 Generate different frequencies & duty in same timer on different channels

  • August 6, 2024
  • 4 replies
  • 1339 views

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.

 

    This topic has been closed for replies.

    4 replies

    Super User
    August 6, 2024

    @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

     

    Super User
    August 6, 2024

    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.)

     

    Graduate II
    August 6, 2024

    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

    Super User
    August 7, 2024

    > 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