arduino / arduino/ArduinoCore-sam
PWML0, PWML1, PWML2, and PWML3 channels for Arduino Due
- Dominant language
- HTML
- Stars
- 91
- Forks
- 112
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I've found a bug and missing things in the SAM core for the Arduino Due (SAM3Xe).
First, I added the channels PWML0, PWML1, PWML2, and PWML3 in the file "hardware\arduino\sam\variants\arduino_due_x\variant.cpp" (pin 34, 36, 38 and 40).
For example for the pin 34 , I replaced the corresponding definition line by :
{ PIOC, PIO_PC2B_PWML0, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM_CH0, NOT_ON_TIMER }, // PWML0 / PIN 34
And so on for the other pins.
I works well for PWML1, PWML2, and PWML3, however when I try to configure PWML0 it doesn't work. I think I know why :
in the file "hardware\arduino\sam\system\libsam\source\pwm.c", line 148 there is this crap line : "pPwm->PWM_CH_NUM[0].PWM_CMR = 1;"
which overwrites any configuration done on channel 0 when configuring other channel. I checked by initializing channel 0 as the last one I configure, and it works.
However modifications done in pwm.c are not taken into account. I guess I have to recompile libsam_sam3x8e_gcc_rel but I don't know how to do that. How can I do to correct this bug until it's fixed ?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with hardware/arduino/sam/variants/arduino_due_x/variant.cpp to review the PWML0–PWML3 mappings, then inspect line 148 of hardware/arduino/sam/system/libsam/source/pwm.c and the libsam_sam3x8e_gcc_rel build target. Reproduce the channel-order behavior, determine how the library is rebuilt, and verify that PWML0 remains configured when the other channels are initialized.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100