Hello,
I have a problem with getting the libray RP2040_PWM to work and can't understand what's going wrong:
I need this library to by able to control the PWM frequency sent to a Hbridge to control the speed of a motor. The actual frequency makes the motor too noisy and that is why I would like to increase te PWM freqhency...
I use a nano RP2040 connect. The board is installed on my IDE and correctly selected in the settings of the IDE. I can install, use libraries, compile and run my other sketches on the board with no problem.
But as soon as I try to use this RP2040_PWM library, I have a compilation error (the sketch does not even begin to download). Below are the sketch and the error message with trying to compile it (PWM_BASIC example from the library) . The error message is the same with any other sketches using this library).
Sketch:
/****************************************************************************************************************************
basic_pwm.ino
For RP2040 boards
Written by Dr. Benjamin Bird
A basic example to get you up and running.
Library by Khoi Hoang https://github.com/khoih-prog/RP2040_PWM
Licensed under MIT license
The RP2040 PWM block has 8 identical slices. Each slice can drive two PWM output signals, or measure the frequency
or duty cycle of an input signal. This gives a total of up to 16 controllable PWM outputs. All 30 GPIO pins can be driven
by the PWM block
*****************************************************************************************************************************/
#define _PWM_LOGLEVEL_ 3
#include "RP2040_PWM.h"
//creates pwm instance
RP2040_PWM* PWM_Instance;
float frequency;
float dutyCycle;
#define pinToUse 10
void setup()
{
//assigns pin 25 (built in LED), with frequency of 20 KHz and a duty cycle of 0%
PWM_Instance = new RP2040_PWM(pinToUse, 20000, 0);
}
void loop()
{
delay(1000);
frequency = 20000;
dutyCycle = 90;
PWM_Instance->setPWM(pinToUse, frequency, dutyCycle);
delay(1000);
dutyCycle = 10;
PWM_Instance->setPWM(pinToUse, frequency, dutyCycle);
}```
Error message on the IDE console when trying to compile.
In file included from C:\Users\bcrep\Document\Arduino\libraries\RP2040_PWM\examples\PWM_Basic\PWM_Basic.ino:17:0:
C:\Users\bcrep\Document\Arduino\libraries\RP2040_PWM\src/RP2040_PWM.h: In member function 'bool RP2040_PWM::setPWM_manual(const uint8_t&, const uint16_t&, const uint8_t&, uint16_t&, bool)':
C:\Users\bcrep\Document\Arduino\libraries\RP2040_PWM\src/RP2040_PWM.h:340:26: error: invalid conversion from 'pwm_config*' to 'uint {aka unsigned int}' [-fpermissive]
pwm_init(_slice_num, &config, true);
^~~~~~~
C:\Users\bcrep\Document\Arduino\libraries\RP2040_PWM\src/RP2040_PWM.h:340:39: error: cannot convert 'bool' to 'pwm_config*' for argument '3' to 'void pwm_init(uint, uint, pwm_config*, bool)'
pwm_init(_slice_num, &config, true);
^
C:\Users\bcrep\Document\Arduino\libraries\RP2040_PWM\src/RP2040_PWM.h: In member function 'bool RP2040_PWM::setPWMPushPull_Int(const uint8_t&, const uint8_t&, const float&, const uint32_t&)':
C:\Users\bcrep\Document\Arduino\libraries\RP2040_PWM\src/RP2040_PWM.h:478:32: error: invalid conversion from 'pwm_config*' to 'uint {aka unsigned int}' [-fpermissive]
pwm_init(_slice_num, &config, true);
^~~~~~~
C:\Users\bcrep\Document\Arduino\libraries\RP2040_PWM\src/RP2040_PWM.h:478:45: error: cannot convert 'bool' to 'pwm_config*' for argument '3' to 'void pwm_init(uint, uint, pwm_config*, bool)'
pwm_init(_slice_num, &config, true);
^
C:\Users\bcrep\Document\Arduino\libraries\RP2040_PWM\src/RP2040_PWM.h: In member function 'bool RP2040_PWM::setPWM_Int(const uint8_t&, const float&, const uint32_t&, bool)':
C:\Users\bcrep\Document\Arduino\libraries\RP2040_PWM\src/RP2040_PWM.h:617:32: error: invalid conversion from 'pwm_config*' to 'uint {aka unsigned int}' [-fpermissive]
pwm_init(_slice_num, &config, true);
^~~~~~~
C:\Users\bcrep\Document\Arduino\libraries\RP2040_PWM\src/RP2040_PWM.h:617:45: error: cannot convert 'bool' to 'pwm_config*' for argument '3' to 'void pwm_init(uint, uint, pwm_config*, bool)'
pwm_init(_slice_num, &config, true);
^
exit status 1
Erreur de compilation pour la carte Arduino Nano RP2040 Connect
Tried to uninstall/reinstall, different releases of the library and different installation methods, with the same result.
I tried also to compile this sketch using the arduino web editor with the same result (same error message).
I saw on the forum plenty of conversations about this library which looks to be great and to work fine, and I don't understand what I am doing wrong... ![]()
Could someone help?
