Giter VIP home page Giter VIP logo

Comments (4)

khoih-prog avatar khoih-prog commented on July 17, 2024

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.

khoih-prog avatar khoih-prog commented on July 17, 2024

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.

americodias avatar americodias commented on July 17, 2024

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.

khoih-prog avatar khoih-prog commented on July 17, 2024

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

  1. Fix bug generating wrong frequency. See Wrong frequency #1

from rp2040_pwm.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.