How to generate 100khz pwm frequency on STM32L476 Nucleo board

STM32F103 Nucleo boards e.g. STM Nucleo F103RB
Post Reply
SHARANYA
Posts: 13
Joined: Fri Aug 18, 2017 8:24 pm

How to generate 100khz pwm frequency on STM32L476 Nucleo board

Post by SHARANYA » Wed Feb 07, 2018 5:53 pm

As the title implies,please give me some clue about how to generate 100khz or more pwm frequency using STM32L476 Nucleo board.I am going to build a Solar charge controller unit for my home use to charge a 150AH SLA battery.I want to build a buck converter using the STM32 board.
Any help is appreciated!!

User avatar
mrburnette
Posts: 2230
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: How to generate 100khz pwm frequency on STM32L476 Nucleo board

Post by mrburnette » Wed Feb 07, 2018 7:08 pm

All Official Nucleo board questions go into this section of the forum:
http://stm32duino.com/viewforum.php?f=29

I will move this post to the appropriate location.


Ray

SHARANYA
Posts: 13
Joined: Fri Aug 18, 2017 8:24 pm

Re: How to generate 100khz pwm frequency on STM32L476 Nucleo board

Post by SHARANYA » Tue Feb 13, 2018 5:24 pm

Come on guys....62 reads,still no reply!!Please help.....

User avatar
mrburnette
Posts: 2230
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: How to generate 100khz pwm frequency on STM32L476 Nucleo board

Post by mrburnette » Tue Feb 13, 2018 7:19 pm

I am sure the issue is that you are specifically asking about a Nucleo board. Yes, there is an official core here https://github.com/stm32duino/Arduino_Core_STM32 But I do not know how many in the forum have your hardware.

Rick talks a little about PWM here: http://stm32duino.com/viewtopic.php?f=4 ... req#p30210


Ray

flussoincrociato
Posts: 11
Joined: Thu Feb 08, 2018 7:13 pm

Re: How to generate 100khz pwm frequency on STM32L476 Nucleo board

Post by flussoincrociato » Fri Feb 16, 2018 12:24 pm

you can try using bit banging as explained here:
https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM
bit banging doesn't requires hardware timer support, if your nucleo has a higher enough clock frequency than UNO, than it's probable that you can reach 100khz with a reasonable duty resolution.
In general, for your application, could be better to spend some time to learn and use a fully supported development system, like keil or other compilers/debuggers suggested by productor.

dannyf
Posts: 231
Joined: Wed May 11, 2016 4:29 pm

Re: How to generate 100khz pwm frequency on STM32L476 Nucleo board

Post by dannyf » Fri Feb 16, 2018 8:41 pm

easy:

1) set the timebase, with a top/prescaler pair set to deliver your frequency;
2) put the output compare / pwm mode to your desired duty cycle.
3) sit back and enjoy.

my code would look something like this:

Code: Select all

  pwm1_init(TMR_PS8x, F_CPU / F_PWM / 8);	//set pwm to generate F_PWM
  pwm1_setdc2(pwm_dc);					//set tmr1/ch2 duty cycle to pwm_dc
now you just need to fill the holes.

Post Reply