cancel
Showing results for 
Search instead for 
Did you mean: 

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

Terje Bøhler
Associate II

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

10 REPLIES 10

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 Up vote any posts that you find helpful, it shows what's working..

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 Up vote any posts that you find helpful, it shows what's working..
Terje Bøhler
Associate II

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

BR Terje

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 Up vote any posts that you find helpful, it shows what's working..

STM32F431?

JW

Terje Bøhler
Associate II

Sorry, STM32L431

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 Up vote any posts that you find helpful, it shows what's working..
Terje Bøhler
Associate II

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 II

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

BR Terje Bøhler