I just uploaded HW PWM servo generation code for the a32u4 mcu. I mostly followed the implementation route for the mega hw pwm servo code that was already there. But I think I found an old error, I would like your comments on:
1. in Output.ino around line 50:
Code: Select all
/**************************************************************************************/
/*************** Software PWM & Servo variables ********************/
/**************************************************************************************/
#if defined(PROMINI) || (defined(PROMICRO) && defined(HWPWM6)) || \
(defined(MEGA) && defined(MEGA_HW_PWM_SERVOS)) || (defined(PROMICRO) && defined(A32U4_4_HW_PWM_SERVOS))
#if defined(SERVO)
#if defined(AIRPLANE) || defined(HELICOPTER)
// To prevent motor to start at reset. atomicServo[7]=5 or 249 if reversed servo
volatile uint8_t atomicServo[8] = {125,125,125,125,125,125,125,5};
#else
volatile uint8_t atomicServo[8] = {125,125,125,125,125,125,125,125};
#endif
#endif
this initializes atomicServo[] even for HW PWM servo use. Some lines later in writeServos() new values are written into atomicServo[]. But atomicServo[] would only ever get used in the ISR(SERVO_ISR) function which is only initialized for soft pwm servo generation ?!?
In essence, I think the macro conditions from the beginning must exclude the HW_PWM_SERVO cases; so really must read like this:
Code: Select all
#if defined(PROMINI) || (defined(PROMICRO) && defined(HWPWM6) && !defined(A32U4_4_HW_PWM_SERVOS)) || \
(defined(MEGA) && !defined(MEGA_HW_PWM_SERVOS)) || (defined(PROMICRO) && !defined(A32U4_4_HW_PWM_SERVOS))
That would remove the entire atomicServo[] code for hw pwm servo use. All this hardware / interrupt handling is way over my head, so I ask for comments from the experts, please.