Hello y'all,
we are developing consumer electronics that include a ERM motor, which buzzes periodically with a defined time interval (like a metronome). The motor is controlled with the DRV2605L in internal trigger mode over I2C, playing haptic effects from the ROM libraries.
I encountered a bug in our firmware: When the interval is considerably small, only every second iteration the motor buzz will be triggered. I suspect that this is happening because at the time I trigger a new haptic effect, the old effect is still being played. Instead of cancelling and playing back the new effect, the DRV2605 ignores the I2C commands to trigger a new effect.
After some investigation and reading the datasheet again I found that I have to clear the GO bit to cancel the current haptic effect and then trigger the new one. However, when I write a 0x00 to address 0x0C (the GO bit address), nothing happens, and the GO bit stays asserted. I tried continuously writing the value in a while loop, and it sometimes takes longer or less long until the command is actually written.
I am wondering what I am missing?
All the best,
Julian
Here's the I2C commands I am sending to play a haptic effect.
// Assert EN
DRV_EN_Write(1);
// De-Assert STANDBY if was asserted / Set MODE to ACTIVE=0x00
IICwriteByte(DRV2605_ADDR, ADDR_MODE, MODE_ACTIVE);
// set library (optional)
IICwriteByte( DRV2605_ADDR, ADDR_LIBRARY, library );
// write waveform ID to 0x04 register (or write mltiple as a sequence from 0x04 to 0x0B)
IICwriteByte( DRV2605_ADDR, ADDR_WAV_SEQ1, effect );
IICwriteByte( DRV2605_ADDR, ADDR_WAV_SEQ2, 0x00 );
// clear the GO BIT if was asserted
goBit = I2C_ReadOneByte( DRV2605_ADDR, ADDR_GO ) & 0x01;
printf("playEffect GO\tBEFORE : %d\t", goBit);
if (goBit == GO) {
while (goBit != STOP) {
IICwriteByte( DRV2605_ADDR, ADDR_GO, STOP );
goBit = I2C_ReadOneByte( DRV2605_ADDR, ADDR_GO ) & 0x01;
printf("GO is %d\r\n", goBit);
}
}
// Set GO bit
IICwriteByte( DRV2605_ADDR, ADDR_GO, GO );