cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F PWM Signal Configuration During Working

BGüçl.1
Associate II

Hello, currently I'm working on a PWM signal generation project. I can generate PWM for certain values. But I need to change them during experiment.

For example, at start PWM going to work on 1KHz freq. and 10ns pulse witdh. Then I'll change them with buttons, first button will add 100Hz and it will be 1100Hz, second button will make it 900Hz and other two buttons will do the same for pulse witdh.

What should I use for that? An example code woulde be great. But I need any ideas, I'm desperate right know.

3 REPLIES 3
TDK
Guru

Once it's started, you can change duty cycle and period by changing the timer's ARR and CCRx registers.

Period is (timer clock) / (PSC + 1) / (ARR + 1).

Duty cycle is CCRx / (ARR + 1).

STM32F isn't a chip, try to be more specific.

If you feel a post has answered your question, please click "Accept as Solution".
BGüçl.1
Associate II

How can I adapt buttons for this? With ADC?

BGüçl.1
Associate II

Btw I'm using STM32F407VG for this project.