Skip to main content
Terje Bøhler
Associate III
Dec 17, 2018 7:44 PM UTC
Question

How can I generate a fixed 200kHz output pulse from my STM32F431?

Hi.

We use a STM32F431 in a project and need to add/include a MCU-port to generate a fixed 200kHz output signal to our target-HW. Many pins on our LQFP64 are already used, so I hope I can use PB6 (TIM16_CH1N) for that purpose.

Q1: How can I set up a (preferably TIM16-) timer to acheive this simple 200kHz pulse?

Q2: Is TIM16 best suited for such a job?

Q3: Where can I find example codes for such TIM-features?

Best regards

Terje Bøhler

    This topic has been closed for replies.

    10 replies

    Tesla DeLorean
    Guru
    Dec 17, 2018 7:53 PM UTC

    Try this, or the other F4 examples as a basis, I know you said 431, they are all much the same

    STM32Cube_FW_F4_V1.23.0\Projects\STM32F413ZH-Nucleo\Examples\TIM\TIM_PWMOutput\Src\main.c

    Perhaps use PMW2 mode, inverts the pulse polarity sense.

    You'd configure PB6, AF mode associating with TIM16

    Divide down the APB clock for TIM to get to 200 KHz, use Prescaler and Period to factor.

    Assume a TIMCLK of 84 MHz,

    Prescaler = 0; // DIV1

    Period = (84000000 / 200000) - 1;

    For 50/50 duty Pulse = (Period+1) /2;

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Tesla DeLorean
    Guru
    Dec 17, 2018 7:56 PM UTC

    Shows configuring N (Complementary) pins

    STM32Cube_FW_F4_V1.23.0\Projects\STM324xG_EVAL\Examples\TIM\TIM_6Steps\Src\main.c

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Terje Bøhler
    Associate III
    Dec 17, 2018 8:00 PM UTC

    Thanks Clive, but where do I find the file/path you are referring to?

    BR Terje

    Tesla DeLorean
    Guru
    Dec 17, 2018 8:51 PM UTC

    The CubeMX F4 installed repositories, or unpack CubeF4 archive

    https://www.st.com/en/embedded-software/stm32cubef4.html

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    waclawek.jan
    Super User
    Dec 17, 2018 9:33 PM UTC

    STM32F431?

    JW

    Terje Bøhler
    Associate III
    Dec 17, 2018 9:37 PM UTC

    Sorry, STM32L431

    Tesla DeLorean
    Guru
    Dec 17, 2018 9:44 PM UTC

    CubeL4 then https://www.st.com/en/embedded-software/stm32cubel4.html

    STM32Cube_FW_L4_V1.13.0\Projects\NUCLEO-L432KC\Examples\TIM\TIM_PWMOutput\Src\main.c

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Terje Bøhler
    Associate III
    Dec 17, 2018 9:57 PM UTC

    Thanks, I now did:

    1) Downloaded "STM32CubeF4 ".

    2) Selected "Open" (I guess) …

    3) Extracted the RAR/ZIP-file to default path ("Extract To …")

    4) Clicked on the "Release_Notes.html" …

    5) The "extraction process" then started: "... extracting from en.stm32cubel4.zip …

    So, what now ?

    No STM32Cub3L4 icon appears …

    Is there an .exe-file to be run?

    BR Terje

    Terje Bøhler
    Associate III
    Dec 17, 2018 9:59 PM UTC

    I very much appreciate further guidance to install/run this STM32CubeL4 …

    BR Terje Bøhler

    Tesla DeLorean
    Guru
    Dec 17, 2018 11:33 PM UTC

    Directories containing software and projects, unpacked where you placed them. Like the old SPL libraries, but now HAL libraries.

    https://community.st.com/s/question/0D50X0000A7VkUNSQ0/problem-downloadingstarting-stm32cubel4

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