Nucleo F103-RB set analogWrtie PWM Frequency

STM32F103 Nucleo boards e.g. STM Nucleo F103RB
Post Reply
nathanS
Posts: 5
Joined: Fri Jul 14, 2017 2:53 pm

Nucleo F103-RB set analogWrtie PWM Frequency

Post by nathanS » Sat Jul 29, 2017 6:04 pm

Hi,

I want to port a motor control sketch to a F103 Nucleo board, but I can't seem to find any an easy way to change the analogWrite PWM frequency.

Currently the code to change from the default pwm frequency to 31khz on pin D9 in the setup block is

Code: Select all

pinMode(9, OUTPUT); // set the motor pin to ouptut
TCCR1B = TCCR1B & 0b11111000 | 0x01; // set PWM frequency to 31khz
I have read some threads on this forum about how to change PWM frquency, but it's not clear to me what's being done. As such, can someone provide well commented code as to how to do this for particular frequencies, and different pins. I am sure this will benefit many others as well.

User avatar
Pito
Posts: 1626
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Nucleo F103-RB set analogWrtie PWM Frequency

Post by Pito » Sat Jul 29, 2017 8:18 pm

Pukao Hats Cleaning Services Ltd.

nathanS
Posts: 5
Joined: Fri Jul 14, 2017 2:53 pm

Re: Nucleo F103-RB set analogWrtie PWM Frequency

Post by nathanS » Sun Jul 30, 2017 3:36 pm

How does one go about installing the libmaple library into the Arduino IDE? Can't find any documentation on how to do this.

User avatar
Pito
Posts: 1626
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Nucleo F103-RB set analogWrtie PWM Frequency

Post by Pito » Sun Jul 30, 2017 5:34 pm

Pukao Hats Cleaning Services Ltd.

Post Reply