Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCx PWM not working correctly #52

Open
josephduchesne opened this issue Jul 29, 2021 · 2 comments
Open

TCx PWM not working correctly #52

josephduchesne opened this issue Jul 29, 2021 · 2 comments
Assignees
Labels
ArduinoCore-samd Label for ArduinoCore-samd UAY Unassigned yet

Comments

@josephduchesne
Copy link

I'm trying to use pwm() on TC4 (D6 on the Seeduino Xiao), but the duty cycle is being calculated incorrectly in wiring_pwm.cpp line 271:

duty = mapResolution(duty, 10, 16);

For samd51 TCx and TCCx, as well as SAMD21 TCCx, it's using:

duty = map(duty, 0, (1<<PWM_API_RESOLUTION), 0, period);

The result is that the counter (in my case duty period = 2000) is being incorrectly.

I've changed the line to match the others and it works fine for my single use case.

@deanm1278 since this was in your original PR, any idea why TCx is treated differently?

@sdkks
Copy link

sdkks commented Nov 20, 2021

I was looking at this #23, then saw this issue as well. I was intending to use the PWM to control motor but I noticed that on oscilloscope that duty cycles are inaccurate. Same device, Xiao (SAMD21)

@MatthewJeffson MatthewJeffson added UAY Unassigned yet ArduinoCore-samd Label for ArduinoCore-samd labels Oct 9, 2024
@Lesords Lesords self-assigned this Oct 14, 2024
@Lesords
Copy link

Lesords commented Oct 16, 2024

Hello,

I'm very sorry to have kept you waiting so long.

Do you still have this problem now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ArduinoCore-samd Label for ArduinoCore-samd UAY Unassigned yet
Projects
Status: Todo
Development

No branches or pull requests

4 participants