ArduinoCore-sam
ArduinoCore-sam copied to clipboard
PWML0, PWML1, PWML2, and PWML3 channels for Arduino Due
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 ?