PWM signal randomly dropping.
I'm working with an STM32L552ZET6Q and two DRV2605L vibration motor drivers (Adafruit breakout board version. Link to chip datasheet below).
The DRVs are configured to drive an LRA coin motor based on a PWM input from the L5 unit; A PWM signal is transmitted from the L5's TIM1 Channel 1 or 2 (pins E9 or E11, depending on which DRV2605L unit I'm using at a given moment). The DRV2605L then changes the strength of attached LRA motor's vibration based on the duty cycle of the PWM signal.
The PWM signal is adjusted via a voltage divider to bring it within a certain voltage range, as using the device without it would cause the DRV to get locked into a certain signal strength if the signal was too high.
For some reason, over a prolonged period of operation, the PWM signal coming from the L5 will randomly drop to a zero duty-cycle before returning to its original level. These drops can occur in quick succession, or with several minutes in between occurrences.
Below is an image of the timer configuration for the PWM drivers in question.
I don't believe this is a power problem, as I am also driving three servo motors in this same setup, and they aren't even jittering when this happens. Whatever is happening appears to be limited to just timer 1.
Below is some of the firmware used to configure the DRV2605L and control the PWM signal to its input.
void init_LRA(struct DRV *lra)
{
writeRegister8(lra, DRV2605_REG_MODE, 0x43);
HAL_Delay(1);
init_driver(lra);
DRV2605_setMode(lra, DRV2605_MODE_PWMANALOG);
HAL_Delay(1);
writeRegister8(lra, DRV2605_REG_CONTROL3, 3);
HAL_Delay(1);
DRV2605_useLRA(lra);
HAL_Delay(1);
DRV2605_selectLibrary(lra, 6);
HAL_Delay(1);
writeRegister8(lra, DRV2605_REG_MODE, 0x03); //change to 0x03 to enable the DRV2605L, or 0x43 to disable the DRV2605L
DRV2605_PWM_Start(lra);
//smoothHaptics(lra, 65);
}void init_driver(struct DRV *drv)
{
writeRegister8(drv, DRV2605_REG_MODE, 0x00);
HAL_Delay(1);
writeRegister8(drv, DRV2605_REG_RTPIN, 0x00);
HAL_Delay(1);
writeRegister8(drv, DRV2605_REG_WAVESEQ1, 0x01);
HAL_Delay(1);
writeRegister8(drv, DRV2605_REG_WAVESEQ2, 0x00);
HAL_Delay(1);
writeRegister8(drv, DRV2605_REG_OVERDRIVE, 0x00);
HAL_Delay(1);
writeRegister8(drv, DRV2605_REG_SUSTAINPOS, 0x00);
HAL_Delay(1);
writeRegister8(drv, DRV2605_REG_SUSTAINNEG, 0x00);
HAL_Delay(1);
writeRegister8(drv, DRV2605_REG_BREAK, 0x00);
HAL_Delay(1);
writeRegister8(drv, DRV2605_REG_AUDIOMAX, 0X64);
HAL_Delay(1);
writeRegister8(drv, DRV2605_REG_FEEDBACK, 0x80);
HAL_Delay(1);
writeRegister8(drv, DRV2605_REG_CONTROL3, 0xA3);
HAL_Delay(1);
writeRegister8(drv, DRV2605_MODE_PWMANALOG, 0x06);
HAL_Delay(1);
}This function is meant to smoothly move the vibration level up and down, rather than having it be so sudden.
If anyone has any explanations/suggestions, that would be great.
edit: Based on further research, I tried enabling auto-reload preload, but that hasn't fixed the problem either.
