Comments (4)
Hi @americodias
Thanks for testing and using the library.
I'm able to duplicate the bug, which seems to happen when freq = 9000-9999Hz
I'll definitely spend time to investigate and fix this interesting bug. Hopefully, the culprit is something in the library, not in the chip.
In the mean time, I'd appreciate if you can make some more tests to see where else the similar issue happens.
Best,
from rp2040_pwm.
Hi,
Already found and fixed the bug, the culprit is the so-called best-fit algorithm. I don't use it now and just use my simple calculation.
Everything will be OK as the following debug terminal shows.
Will publish a new version by tomorrow, with your contribution noted.
Best Regards,
===
Starting PWM_Multi on RaspberryPi Pico
RP2040_PWM v1.0.0
=============================================================
Index Pin PWM_freq DutyCycle Actual Freq
=============================================================
0 2 200000.00 50[PWM] _PWM_config.top =624, _actualFrequency =200000.00
200000.00
[PWM] TOP = 624, DIV = 1, CPU_freq = 125000000 =================> PWM = 200000 !!!
=============================================================
Starting PWM_Multi on RaspberryPi Pico
RP2040_PWM v1.0.0
=============================================================
Index Pin PWM_freq DutyCycle Actual Freq
=============================================================
0 2 8999.00 50[PWM] _PWM_config.top =13889, _actualFrequency =8999.00
8999.00
[PWM] TOP = 13889, DIV = 1, CPU_freq = 125000000 =================> PWM = 8999.2 !!!
=============================================================
Starting PWM_Multi on RaspberryPi Pico
RP2040_PWM v1.0.0
=============================================================
Index Pin PWM_freq DutyCycle Actual Freq
=============================================================
0 2 9000.00 50[PWM] _PWM_config.top =13887, _actualFrequency =9000.00
9000.00
[PWM] TOP = 13887, DIV = 1, CPU_freq = 125000000 =================> PWM = 9000.576 !!!
=============================================================
Starting PWM_Multi on RaspberryPi Pico
RP2040_PWM v1.0.0
=============================================================
Index Pin PWM_freq DutyCycle Actual Freq
=============================================================
0 2 2000.00 50[PWM] _PWM_config.top =62499, _actualFrequency =2000.00
2000.00
[PWM] TOP = 62499, DIV = 1, CPU_freq = 125000000 =================> PWM = 2000 !!!
=============================================================
Starting PWM_Multi on RaspberryPi Pico
RP2040_PWM v1.0.0
=============================================================
Index Pin PWM_freq DutyCycle Actual Freq
=============================================================
0 2 1000.00 50[PWM] _PWM_config.top =12499, _actualFrequency =1000.00
1000.00
[PWM] TOP = 12499, DIV = 10, CPU_freq = 125000000 =================> PWM = 1000 !!!
=============================================================
Starting PWM_Multi on RaspberryPi Pico
RP2040_PWM v1.0.0
=============================================================
Index Pin PWM_freq DutyCycle Actual Freq
=============================================================
0 2 1000.00 50[PWM] _PWM_config.top =12499, _actualFrequency =1000.00
1000.00
[PWM] TOP = 12499, DIV = 10, CPU_freq = 125000000 =================> PWM = 1000 !!!
=============================================================
Starting PWM_Multi on RaspberryPi Pico
RP2040_PWM v1.0.0
=============================================================
Index Pin PWM_freq DutyCycle Actual Freq
=============================================================
0 2 500.00 50[PWM] _PWM_config.top =24999, _actualFrequency =500.00
500.00
[PWM] TOP = 24999, DIV = 10, CPU_freq = 125000000 =================> PWM = 500 !!!
=============================================================
Starting PWM_Multi on RaspberryPi Pico
RP2040_PWM v1.0.0
=============================================================
Index Pin PWM_freq DutyCycle Actual Freq
=============================================================
0 2 50.00 50[PWM] _PWM_config.top =24999, _actualFrequency =50.00
50.00
[PWM] TOP = 24999, DIV = 100, CPU_freq = 125000000 =================> PWM = 50 !!!
=============================================================
Starting PWM_Multi on RaspberryPi Pico
RP2040_PWM v1.0.0
=============================================================
Index Pin PWM_freq DutyCycle Actual Freq
=============================================================
0 2 10.00 50[PWM] _PWM_config.top =62499, _actualFrequency =10.00
10.00
[PWM] TOP = 62499, DIV = 200, CPU_freq = 125000000 =================> PWM = 10 !!!
=============================================================
Starting PWM_Multi on RaspberryPi Pico
RP2040_PWM v1.0.0
=============================================================
Index Pin PWM_freq DutyCycle Actual Freq
=============================================================
0 2 7.50 50[PWM] _PWM_config.top =65358, _actualFrequency =7.00
7.00
[PWM] TOP = 65358, DIV = 255, CPU_freq = 125000000 =================> PWM = 7.5 !!!
=============================================================
from rp2040_pwm.
Hi @khoih-prog,
That was fast! Thank you for creating this library and for the quick fix!
I will use this library for an ongoing project and will let you know if I find any other issues.
Kind regards,
Américo
from rp2040_pwm.
Hi @americodias
The new RP2040_PW releases v1.0.1 has just been published
Your contribution has been noted in Contributions and Thanks
Thanks to the contributions of users like you, the library will have good chance to be better and better, with less and less bugs.
Releases v1.0.1
- Fix bug generating wrong frequency. See Wrong frequency #1
from rp2040_pwm.
Related Issues (11)
- Changing Duty Cycle Dynamically Creates Runt PWM pulse HOT 4
- PWM_Basic example fails to blink LED on Pico W HOT 3
- Using PWM to step a stepper driver HOT 17
- Change the PWM frequency HOT 5
- Attempting to Alter the Duty Cycle w/o changing any other values HOT 4
- Setting duty cycle without disturbing frequency HOT 3
- Request for Clarification on PWM Slices and A/B sides HOT 2
- Duty cycle as integer rather than float HOT 19
- Frequency and Duty Cycle Measurement HOT 1
- Measuring Duty Cycle Example HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rp2040_pwm.