DRV2605L problem: cannot write/read register LIBRARY_SEL

Breakout boards, sensors, Drawdio, Game of Life, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Post Reply
User avatar
MarcusHS
 
Posts: 6
Joined: Tue Aug 16, 2022 12:05 pm

DRV2605L problem: cannot write/read register LIBRARY_SEL

Post by MarcusHS »

Hi everyone,

I have some trouble with the DRV2605l haptic driver and I am quite lost what else to try, so here is my problem maybe someone can push me to the right direction..

I am using the adafruit DRV2605l breakout board connected to a LRA (tried a coin shaped one and a rectangular one, i dont have a datasheet to either). I am using an ESP32-C3 as a µC (also tried Arduino Uno, same results). Using a different breakoutboard with the same chip gives me the exact same results.
I soldered pin headers to the breakoutboard and am using jumper wires to connect the board to the µC, power and the LRA. Voltage of the ESP32 is 3.3V therefore I also power the breakout board with 3.3V (from one of the 3.3V pins of the ESP32).

I tried the standard adafruit library but without success so I started modifying this library. Now I am able to connect to the DRV2605 using I2C and I can write and read (almost all) registers of the DRV, ...except for the bits [2:0] of the register 0x03 (which are the LIBRARY_SEL bits): As long as the last 3 bits I write to reg 0x03 are 000 I can write to this register and read the outcome. For example if I write into the reg-address 0x03 the value of 0xA0 (B10100000) and then read back this register I see that it is set to the correct value. This works with any value as long as the last 3 bits are 0. When I write any value that has any bits of value 1 in the last 3 places (eg 0x03 B00000110) and then read back the result, the values of the first 5 bits have changed but bits [2:0] are unchanged. The datasheet says R/W but I cant seem to read the values of these bits and therefore I dont know if the values have changed or not.
The connected LRA does not respond to the DRV2605 in the right way: buzz at "go" (writing 0x01 to addr 0x0c), but always a very similar one, no matter which pattern I have selected from the Waveform sequencer registry before sending "go".
I have done the autocalibration function as described in the datasheet, but here I also find some weird behaviour as the results are always the same no matter which LRA/ERM I connect, or even without anything connected to the motor pins at all.

Here is my Code of the modified Library .cpp:

Code: Select all

/*!
 * @file Adafruit_DRV2605.cpp
 *
 * @mainpage Adafruit DRV2605L Haptic Driver
 *
 * @section intro_sec Introduction
 *
 * This is a library for the Adafruit DRV2605L Haptic Driver ---->
 * http://www.adafruit.com/products/2305
 *
 * Check out the links above for our tutorials and wiring diagrams.
 *
 * This motor/haptic driver uses I2C to communicate.
 *
 * Adafruit invests time and resources providing this open source code,
 * please support Adafruit and open-source hardware by purchasing
 * products from Adafruit!
 *
 * @section author Author
 *
 * Written by Limor Fried/Ladyada for Adafruit Industries.
 *
 * @section license License
 *
 * MIT license, all text above must be included in any redistribution.
 *
 */
/**************************************************************************/

#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

#include <Adafruit_DRV2605.h>

/*========================================================================*/
/*                            CONSTRUCTORS                                */
/*========================================================================*/

/**************************************************************************/
/*!
  @brief  Instantiates a new DRV2605 class. I2C, no address adjustments or pins
*/
/**************************************************************************/
Adafruit_DRV2605::Adafruit_DRV2605() {}

/*========================================================================*/
/*                           PUBLIC FUNCTIONS                             */
/*========================================================================*/

/**************************************************************************/
/*!
  @brief Setup HW using a specified Wire
  @param theWire Pointer to a TwoWire object, defaults to &Wire
  @return Return value from init()
*/
/**************************************************************************/
bool Adafruit_DRV2605::begin(TwoWire *theWire) {
  if (i2c_dev)
    delete i2c_dev;
  i2c_dev = new Adafruit_I2CDevice(DRV2605_ADDR, theWire);
  delay(1000);
  return init();
}

/**************************************************************************/
/*!
  @brief  Setup the HW
  @return Always true
*/
/**************************************************************************/
bool Adafruit_DRV2605::init() {
  if (!i2c_dev->begin())
    return false;
  uint8_t id = readRegister8(DRV2605_REG_STATUS);
  Serial.print("Status... read: 0x"); Serial.println(id, HEX);

  //Reset Chip
  writeRegister8(DRV2605_REG_MODE,0x80);

  Serial.println("Resetting...");
  delay(1000);
  Serial.println("Resetting...");
  delay(1000);


  //Print all register values
  Serial.println("");
  Serial.println("Chip registers reset to default values...");
  Serial.println("");
  delay(1000);
  printRegisters();
  delay(2000);
  
  
  
  //Try writing different values to LIB Register to see which work and which don't
  writeRegister8(DRV2605_REG_LIBRARY, B10000000);
  writeRegister8(DRV2605_REG_LIBRARY, B01000000);
  writeRegister8(DRV2605_REG_LIBRARY, B00100000);
  writeRegister8(DRV2605_REG_LIBRARY, B00010000);
  writeRegister8(DRV2605_REG_LIBRARY, B00001000);
  writeRegister8(DRV2605_REG_LIBRARY, B00000100);
  writeRegister8(DRV2605_REG_LIBRARY, B00000010);
  writeRegister8(DRV2605_REG_LIBRARY, B00000001);

  writeRegister8(DRV2605_REG_LIBRARY, B00000011);
  writeRegister8(DRV2605_REG_LIBRARY, B00000111);
  writeRegister8(DRV2605_REG_LIBRARY, B00000110);

  writeRegister8(DRV2605_REG_LIBRARY, B10000001);
  writeRegister8(DRV2605_REG_LIBRARY, B10000010);


  writeRegister8(DRV2605_REG_LIBRARY, 0x00);
  writeRegister8(DRV2605_REG_LIBRARY, 0x06);
  writeRegister8(DRV2605_REG_LIBRARY, 0xA0);
  writeRegister8(DRV2605_REG_LIBRARY, 0x06);
  writeRegister8(DRV2605_REG_LIBRARY, B11010111);
  writeRegister8(DRV2605_REG_LIBRARY, B10101111);

  autoCal();

  
  //Set register values according to Datasheet
  Serial.println("standby-mode off ");
  writeRegister8(DRV2605_REG_MODE, 0x00); 

  Serial.println("voltage_set  ");
  writeRegister8(DRV2605_REG_RATEDV, 0x53); 

  Serial.println("overvoltage  ");
  writeRegister8(DRV2605_REG_CLAMPV, 0x89); 

  Serial.println("feedback  ");
  writeRegister8(DRV2605_REG_FEEDBACK, 0xB6); 

  Serial.println("contol1 ");
  writeRegister8(DRV2605_REG_CONTROL1, 0x13); 
  
  Serial.println("contol2  ");
  writeRegister8(DRV2605_REG_CONTROL2, 0xF5); 

  Serial.println("control3  ");
  writeRegister8(DRV2605_REG_CONTROL3, 0x80); 

  Serial.println("Lib select  ");
  writeRegister8(DRV2605_REG_LIBRARY, 0x06); 
  
  Serial.println("active mode  ");
  writeRegister8(DRV2605_REG_MODE, 0x00); 


  //Print all register values
  printRegisters();
  

  // Serial.println("testing which library hex values can be set for lib-select registry");
  
  // int lib_value;
  // int read_lib_value;
  // for (lib_value = 0x0; lib_value <= 0xff; lib_value++)
  // {
  
  //   Serial.print("Reg 0x03 |  ");
  //   Serial.print(lib_value);
  //   Serial.print("   |   WRITE - HEX: 0x");
  //   Serial.print(lib_value,HEX);
  //   Serial.print("  bits: ");
  //   Serial.print(lib_value,BIN);

  //   writeRegister8(DRV2605_REG_LIBRARY, lib_value); 
  //   delay(100);
  //   read_lib_value = readRegister8(DRV2605_REG_LIBRARY);
  //   Serial.print(" |   READ - HEX: 0x");
  //   Serial.print(read_lib_value,HEX);
  //   Serial.print("  bits: ");
  //   Serial.print(read_lib_value,BIN);
  //   if (read_lib_value == lib_value) {
  //     Serial.println("   <---------  worked! ");
  //   }
  //   else Serial.println("");
  // }


  delay(1000);
  return true;
}

/**************************************************************************/
/*!
  @brief Select the haptic waveform to use.
  @param slot The waveform slot to set, from 0 to 7
  @param w The waveform sequence value, refers to an index in the ROM library.

    Playback starts at slot 0 and continues through to slot 7, stopping if it
  encounters a value of 0. A list of available waveforms can be found in
  section 11.2 of the datasheet: http://www.adafruit.com/datasheets/DRV2605.pdf
*/
/**************************************************************************/
void Adafruit_DRV2605::setWaveform(uint8_t slot, uint8_t w) {
  writeRegister8(DRV2605_REG_WAVESEQ1 + slot, w);
}




/**************************************************************************/
/*!
  @brief Select the waveform library to use.
  @param lib Library to use, 0 = Empty, 1-5 are ERM, 6 is LRA.

    See section 7.6.4 in the datasheet for more details:
  http://www.adafruit.com/datasheets/DRV2605.pdf
*/
/**************************************************************************/
void Adafruit_DRV2605::selectLibrary(uint8_t lib) {
  writeRegister8(DRV2605_REG_LIBRARY, lib);
}




/**************************************************************************/
/*!
  @brief Reads and prints all register values mentioned in the Datasheet

    See section 7.6.4 in the datasheet for more details:
  http://www.adafruit.com/datasheets/DRV2605.pdf
*/
/**************************************************************************/
void Adafruit_DRV2605::printRegisters() {

  int reg_addr;
  int reg_val;

   //Print all register values
  Serial.println("sweep through all registries and print values...");
  for (reg_addr = 0x0; reg_addr <= 0x22; reg_addr++)
  {
    Serial.print("Reg 0x");
    Serial.print(reg_addr, HEX);
    reg_val = readRegister8(reg_addr);
    Serial.print(" |   HEX: 0x");
    Serial.print(reg_val,HEX);
    Serial.print(" |   bits: ");
    Serial.println(reg_val,BIN);
  }
}





/**************************************************************************/
/*!
  @brief Start playback of the waveforms (start moving!).
*/
/**************************************************************************/
void Adafruit_DRV2605::go() { writeRegister8(DRV2605_REG_GO, 1); }




/**************************************************************************/
/*!
  @brief Stop playback.
*/
/**************************************************************************/
void Adafruit_DRV2605::stop() { writeRegister8(DRV2605_REG_GO, 0); }




/**************************************************************************/
/*!
  @brief Set the device mode.
  @param mode Mode value, see datasheet section 7.6.2:
  http://www.adafruit.com/datasheets/DRV2605.pdf

    0: Internal trigger, call go() to start playback\n
    1: External trigger, rising edge on IN pin starts playback\n
    2: External trigger, playback follows the state of IN pin\n
    3: PWM/analog input\n
    4: Audio\n
    5: Real-time playback\n
    6: Diagnostics\n
    7: Auto calibration
*/
/**************************************************************************/
void Adafruit_DRV2605::setMode(uint8_t mode) {
  writeRegister8(DRV2605_REG_MODE, mode);
}




/**************************************************************************/
/*!
  @brief Set the realtime value when in RTP mode, used to directly drive the
  haptic motor.
  @param rtp 8-bit drive value.
*/
/**************************************************************************/
void Adafruit_DRV2605::setRealtimeValue(uint8_t rtp) {
  writeRegister8(DRV2605_REG_RTPIN, rtp);
}




/**************************************************************************/
/*!
  @brief Read an 8-bit register.
  @param reg The register to read.
  @return 8-bit value of the register.
*/
/**************************************************************************/
uint8_t Adafruit_DRV2605::readRegister8(uint8_t reg) {
  uint8_t buffer[1] = {reg};
  i2c_dev->write_then_read(buffer, 1, buffer, 1);
  return buffer[0];
}




/**************************************************************************/
/*!
  @brief Write an 8-bit register.
  @param reg The register to write.
  @param val The value to write.
*/
/**************************************************************************/
void Adafruit_DRV2605::writeRegister8(uint8_t reg, uint8_t val) {
  uint8_t readback;
  uint8_t buffer[2] = {reg, val};
  Serial.print("(0x");
  Serial.print(reg,HEX);
  Serial.print(")  write: 0x");
  Serial.print(val,HEX);
  Serial.print("  (");
  Serial.print(val,BIN);
  Serial.print(") ");

  if (i2c_dev->write(buffer, 2)){
    delay(200);
    readback = readRegister8(reg);
    Serial.print("   |   read: 0x");
    Serial.print(readback,HEX); 
    Serial.print("  (");
    Serial.print(readback,BIN);
    Serial.print(") ");
    if (readback != val) {
      Serial.println("   <------------- did not work!! ");
    }
  }

  else {
     Serial.println("Write fail"); 
  }

  Serial.println("");

}




/**************************************************************************/
/*!
  @brief Use ERM (Eccentric Rotating Mass) mode.
*/
/**************************************************************************/
void Adafruit_DRV2605::useERM() {
  writeRegister8(DRV2605_REG_FEEDBACK,
                 readRegister8(DRV2605_REG_FEEDBACK) & 0x7F);
}




/**************************************************************************/
/*!
  @brief Use LRA (Linear Resonance Actuator) mode.
*/
/**************************************************************************/
void Adafruit_DRV2605::useLRA() {
  writeRegister8(DRV2605_REG_FEEDBACK,
                 readRegister8(DRV2605_REG_FEEDBACK) | 0x80);
}





/**************************************************************************/
/*!
  @brief Autocalibrate routine according to Datasheet
*/
/**************************************************************************/
void Adafruit_DRV2605::autoCal(void) {

  unsigned char temp = 0x00;
  unsigned char ACalComp, ACalBEMF, BEMFGain;


  writeRegister8(DRV2605_REG_RATEDV, 0x50); // into standby
  Serial.println("voltage_set");
  writeRegister8(DRV2605_REG_CLAMPV, 0x89); // into standby
  Serial.println("overvoltage");
  writeRegister8(DRV2605_REG_FEEDBACK, 0xB6); // into standby
  Serial.println("feedback");
  writeRegister8(DRV2605_REG_CONTROL1, 0x93); //
  Serial.println("contol1");
  writeRegister8(DRV2605_REG_CONTROL2, 0xF5); // into standby
  Serial.println("contol2");
  writeRegister8(DRV2605_REG_CONTROL3, 0x80); // into standby
  Serial.println("control3");
  writeRegister8(DRV2605_REG_MODE, 0x07); // into standby
  Serial.println("autoCalibrationMode");
  writeRegister8(DRV2605_REG_CONTROL4, 0x20); // into standby
  Serial.println("control4");
  writeRegister8(DRV2605_REG_GO, 0x01); // into standby
  Serial.println("GO Autocalibration... !");



  temp = readRegister8(DRV2605_REG_GO);
  Serial.print("STATUS_Reg: 0x");
	Serial.println(temp, HEX);

  if ((temp & 0x08) != 0x00)
	{
    Serial.println("DRV2605 Auto-calibration fail");
	}
  else {

	Serial.println("DRV2605 Auto-calibration complete");
  }


  ACalComp = readRegister8(DRV2605_REG_AUTOCALCOMP);
  Serial.print("Auto-Calibration Compensation Result: 0x");
	Serial.println(ACalComp, HEX);

  ACalBEMF = readRegister8(DRV2605_REG_AUTOCALEMP);
  Serial.print("Auto-Calibration Back-EMF Result: 0x");
	Serial.println(ACalBEMF, HEX);

  BEMFGain = readRegister8(DRV2605_REG_FEEDBACK);
  Serial.print("Feedback Control: 0x");
	Serial.println(BEMFGain, HEX);

  Serial.print("Analog gain of the back-EMF amplifier: ");
	if ((BEMFGain & 0x03) == 0) Serial.println("5x");
	else if ((BEMFGain & 0x03) == 1) Serial.println("10x");
	else if ((BEMFGain & 0x03) == 2) Serial.println("20x");
	else Serial.println("30x");

}

Here the Library .h file:

Code: Select all


/*!
 * @file Adafruit_DRV2605.h
 *
 * This is a library for the Adafruit DRV2605L Haptic Driver ---->
 * http://www.adafruit.com/products/2305
 *
 * Check out the links above for our tutorials and wiring diagrams.
 *
 * This motor/haptic driver uses I2C to communicate.
 *
 * Adafruit invests time and resources providing this open source code,
 * please support Adafruit and open-source hardware by purchasing
 * products from Adafruit!
 *
 * Written by Limor Fried/Ladyada for Adafruit Industries.
 *
 * MIT license, all text above must be included in any redistribution.
 *
 */
/**************************************************************************/

#ifndef _ADAFRUIT_DRV2605_H
#define _ADAFRUIT_DRV2605_H

#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

#include <Adafruit_I2CDevice.h>

#define DRV2605_ADDR 0x5A ///< Device I2C address

#define DRV2605_REG_STATUS 0x00       ///< Status register
#define DRV2605_REG_MODE 0x01         ///< Mode register
// #define DRV2605_MODE_INTTRIG 0x00     ///< Internal trigger mode
// #define DRV2605_MODE_EXTTRIGEDGE 0x01 ///< External edge trigger mode
// #define DRV2605_MODE_EXTTRIGLVL 0x02  ///< External level trigger mode
// #define DRV2605_MODE_PWMANALOG 0x03   ///< PWM/Analog input mode
// #define DRV2605_MODE_AUDIOVIBE 0x04   ///< Audio-to-vibe mode
// #define DRV2605_MODE_REALTIME 0x05    ///< Real-time playback (RTP) mode
// #define DRV2605_MODE_DIAGNOS 0x06     ///< Diagnostics mode
// #define DRV2605_MODE_AUTOCAL 0x07     ///< Auto calibration mode

#define DRV2605_REG_RTPIN 0x02    ///< Real-time playback input register
#define DRV2605_REG_LIBRARY 0x03  ///< Waveform library selection register
#define DRV2605_REG_WAVESEQ1 0x04 ///< Waveform sequence register 1
#define DRV2605_REG_WAVESEQ2 0x05 ///< Waveform sequence register 2
#define DRV2605_REG_WAVESEQ3 0x06 ///< Waveform sequence register 3
#define DRV2605_REG_WAVESEQ4 0x07 ///< Waveform sequence register 4
#define DRV2605_REG_WAVESEQ5 0x08 ///< Waveform sequence register 5
#define DRV2605_REG_WAVESEQ6 0x09 ///< Waveform sequence register 6
#define DRV2605_REG_WAVESEQ7 0x0A ///< Waveform sequence register 7
#define DRV2605_REG_WAVESEQ8 0x0B ///< Waveform sequence register 8

#define DRV2605_REG_GO 0x0C         ///< Go register
#define DRV2605_REG_OVERDRIVE 0x0D  ///< Overdrive time offset register
#define DRV2605_REG_SUSTAINPOS 0x0E ///< Sustain time offset, positive register
#define DRV2605_REG_SUSTAINNEG 0x0F ///< Sustain time offset, negative register
#define DRV2605_REG_BREAK 0x10      ///< Brake time offset register
#define DRV2605_REG_AUDIOCTRL 0x11  ///< Audio-to-vibe control register
#define DRV2605_REG_AUDIOLVL                                                   \
  0x12 ///< Audio-to-vibe minimum input level register
#define DRV2605_REG_AUDIOMAX                                                   \
  0x13 ///< Audio-to-vibe maximum input level register
#define DRV2605_REG_AUDIOOUTMIN                                                \
  0x14 ///< Audio-to-vibe minimum output drive register
#define DRV2605_REG_AUDIOOUTMAX                                                \
  0x15                          ///< Audio-to-vibe maximum output drive register
#define DRV2605_REG_RATEDV 0x16 ///< Rated voltage register
#define DRV2605_REG_CLAMPV 0x17 ///< Overdrive clamp voltage register
#define DRV2605_REG_AUTOCALCOMP                                                \
  0x18 ///< Auto-calibration compensation result register
#define DRV2605_REG_AUTOCALEMP                                                 \
  0x19                            ///< Auto-calibration back-EMF result register
#define DRV2605_REG_FEEDBACK 0x1A ///< Feedback control register
#define DRV2605_REG_CONTROL1 0x1B ///< Control1 Register
#define DRV2605_REG_CONTROL2 0x1C ///< Control2 Register
#define DRV2605_REG_CONTROL3 0x1D ///< Control3 Register
#define DRV2605_REG_CONTROL4 0x1E ///< Control4 Register
#define DRV2605_REG_VBAT 0x21     ///< Vbat voltage-monitor register
#define DRV2605_REG_LRARESON 0x22 ///< LRA resonance-period register

/**************************************************************************/
/*!
  @brief The DRV2605 driver class.
*/
/**************************************************************************/
class Adafruit_DRV2605 {
public:
  Adafruit_DRV2605(void);
  bool begin(TwoWire *theWire = &Wire);

  bool init();
  void writeRegister8(uint8_t reg, uint8_t val);
  void printRegisters();
  uint8_t readRegister8(uint8_t reg);
  void setWaveform(uint8_t slot, uint8_t w);
  void selectLibrary(uint8_t lib);
  void go(void);
  void stop(void);
  void setMode(uint8_t mode);
  void setRealtimeValue(uint8_t rtp);
  // Select ERM (Eccentric Rotating Mass) or LRA (Linear Resonant Actuator)
  // vibration motor The default is ERM, which is more common
  void useERM();
  void useLRA();
  void autoCal(void);

private:
  Adafruit_I2CDevice *i2c_dev = NULL; ///< Pointer to I2C bus interface
};

#endif
And here my Arduino Code:

Code: Select all

#include <Wire.h>
#include "Adafruit_DRV2605.h"
#include "Freenove_WS2812_Lib_for_ESP32.h"

#define LEDS_PIN  8
#define CHANNEL   0
int LED = 3;
int IN_DRV = 10;

//#define I2C_SDA 5
//#define I2C_SCL 6

TwoWire I2C_DRV = TwoWire(0);

Freenove_ESP32_WS2812 strip = Freenove_ESP32_WS2812(1, LEDS_PIN, CHANNEL, TYPE_GRB);


Adafruit_DRV2605 drv;

void setup() {

  Serial.begin(115200);
  //----------------------- LED-RGB ---------------------------------------
  strip.begin();
  strip.setBrightness(20);
  for (int j = 0; j < 255; j += 2) {
    for (int i = 0; i < 1; i++) {
      strip.setLedColorData(i, strip.Wheel((i * 256 / 1 + j) & 255));
    }
    strip.show();
    delay(10);
  }
  delay(1000);
  strip.setLedColorData(0, 0, 0, 0);
  strip.show();
  // ---------------------------------------------------------------------

  //----------------------- I2C Scan --------------------------------
  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  Wire.begin(5, 6);
  for (byte i = 8; i < 120; i++)
  {
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
    {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (1); // maybe unneeded?
    } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
  delay(1000);
  //-------------------------------------------------------------


  //-------------------------- DRV2605L INIT ---------------------------

  Serial.println("Adafruit DRV2605 Basic test");

  I2C_DRV.begin(5, 6);
  bool status_drv;
  status_drv = drv.begin(&I2C_DRV);

  if (! status_drv) {
    Serial.println("Could not find DRV2605");
    while (1) delay(1000);
  }

  drv.autoCal();
  drv.printRegisters();


  //----------------------------------------------------------------
}

uint8_t effect = 1;

void loop() {
  //  Serial.print("Effect #"); Serial.println(effect);

  if (effect == 1) {
    Serial.println("11.2 Waveform Library Effects List");
  }

  if (effect == 1) {
    Serial.println(F("1 − Strong Click - 100%"));
  }
  if (effect == 2) {
    Serial.println(F("2 − Strong Click - 60%"));
  }
  if (effect == 3) {
    Serial.println(F("3 − Strong Click - 30%"));
  }
  if (effect == 4) {
    Serial.println(F("4 − Sharp Click - 100%"));
  }
  if (effect == 5) {
    Serial.println(F("5 − Sharp Click - 60%"));
  }
  if (effect == 6) {
    Serial.println(F("6 − Sharp Click - 30%"));
  }
  if (effect == 7) {
    Serial.println(F("7 − Soft Bump - 100%"));
  }
  if (effect == 8) {
    Serial.println(F("8 − Soft Bump - 60%"));
  }
  if (effect == 9) {
    Serial.println(F("9 − Soft Bump - 30%"));
  }
  if (effect == 10) {
    Serial.println(F("10 − Double Click - 100%"));
  }
  if (effect == 11) {
    Serial.println(F("11 − Double Click - 60%"));
  }
  if (effect == 12) {
    Serial.println(F("12 − Triple Click - 100%"));
  }
  if (effect == 13) {
    Serial.println(F("13 − Soft Fuzz - 60%"));
  }
  if (effect == 14) {
    Serial.println(F("14 − Strong Buzz - 100%"));
  }
  if (effect == 15) {
    Serial.println(F("15 − 750 ms Alert 100%"));
  }
  if (effect == 16) {
    Serial.println(F("16 − 1000 ms Alert 100%"));
  }
  if (effect == 17) {
    Serial.println(F("17 − Strong Click 1 - 100%"));
  }
  if (effect == 18) {
    Serial.println(F("18 − Strong Click 2 - 80%"));
  }
  if (effect == 19) {
    Serial.println(F("19 − Strong Click 3 - 60%"));
  }
  if (effect == 20) {
    Serial.println(F("20 − Strong Click 4 - 30%"));
  }
  if (effect == 21) {
    Serial.println(F("21 − Medium Click 1 - 100%"));
  }
  if (effect == 22) {
    Serial.println(F("22 − Medium Click 2 - 80%"));
  }
  if (effect == 23) {
    Serial.println(F("23 − Medium Click 3 - 60%"));
  }
  if (effect == 24) {
    Serial.println(F("24 − Sharp Tick 1 - 100%"));
  }
  if (effect == 25) {
    Serial.println(F("25 − Sharp Tick 2 - 80%"));
  }
  if (effect == 26) {
    Serial.println(F("26 − Sharp Tick 3 – 60%"));
  }
  if (effect == 27) {
    Serial.println(F("27 − Short Double Click Strong 1 – 100%"));
  }
  if (effect == 28) {
    Serial.println(F("28 − Short Double Click Strong 2 – 80%"));
  }
  if (effect == 29) {
    Serial.println(F("29 − Short Double Click Strong 3 – 60%"));
  }
  if (effect == 30) {
    Serial.println(F("30 − Short Double Click Strong 4 – 30%"));
  }
  if (effect == 31) {
    Serial.println(F("31 − Short Double Click Medium 1 – 100%"));
  }
  if (effect == 32) {
    Serial.println(F("32 − Short Double Click Medium 2 – 80%"));
  }
  if (effect == 33) {
    Serial.println(F("33 − Short Double Click Medium 3 – 60%"));
  }
  if (effect == 34) {
    Serial.println(F("34 − Short Double Sharp Tick 1 – 100%"));
  }
  if (effect == 35) {
    Serial.println(F("35 − Short Double Sharp Tick 2 – 80%"));
  }
  if (effect == 36) {
    Serial.println(F("36 − Short Double Sharp Tick 3 – 60%"));
  }
  if (effect == 37) {
    Serial.println(F("37 − Long Double Sharp Click Strong 1 – 100%"));
  }
  if (effect == 38) {
    Serial.println(F("38 − Long Double Sharp Click Strong 2 – 80%"));
  }
  if (effect == 39) {
    Serial.println(F("39 − Long Double Sharp Click Strong 3 – 60%"));
  }
  if (effect == 40) {
    Serial.println(F("40 − Long Double Sharp Click Strong 4 – 30%"));
  }
  if (effect == 41) {
    Serial.println(F("41 − Long Double Sharp Click Medium 1 – 100%"));
  }
  if (effect == 42) {
    Serial.println(F("42 − Long Double Sharp Click Medium 2 – 80%"));
  }
  if (effect == 43) {
    Serial.println(F("43 − Long Double Sharp Click Medium 3 – 60%"));
  }
  if (effect == 44) {
    Serial.println(F("44 − Long Double Sharp Tick 1 – 100%"));
  }
  if (effect == 45) {
    Serial.println(F("45 − Long Double Sharp Tick 2 – 80%"));
  }
  if (effect == 46) {
    Serial.println(F("46 − Long Double Sharp Tick 3 – 60%"));
  }
  if (effect == 47) {
    Serial.println(F("47 − Buzz 1 – 100%"));
  }
  if (effect == 48) {
    Serial.println(F("48 − Buzz 2 – 80%"));
  }
  if (effect == 49) {
    Serial.println(F("49 − Buzz 3 – 60%"));
  }
  if (effect == 50) {
    Serial.println(F("50 − Buzz 4 – 40%"));
  }
  if (effect == 51) {
    Serial.println(F("51 − Buzz 5 – 20%"));
  }
  if (effect == 52) {
    Serial.println(F("52 − Pulsing Strong 1 – 100%"));
  }
  if (effect == 53) {
    Serial.println(F("53 − Pulsing Strong 2 – 60%"));
  }
  if (effect == 54) {
    Serial.println(F("54 − Pulsing Medium 1 – 100%"));
  }
  if (effect == 55) {
    Serial.println(F("55 − Pulsing Medium 2 – 60%"));
  }
  if (effect == 56) {
    Serial.println(F("56 − Pulsing Sharp 1 – 100%"));
  }
  if (effect == 57) {
    Serial.println(F("57 − Pulsing Sharp 2 – 60%"));
  }
  if (effect == 58) {
    Serial.println(F("58 − Transition Click 1 – 100%"));
  }
  if (effect == 59) {
    Serial.println(F("59 − Transition Click 2 – 80%"));
  }
  if (effect == 60) {
    Serial.println(F("60 − Transition Click 3 – 60%"));
  }
  if (effect == 61) {
    Serial.println(F("61 − Transition Click 4 – 40%"));
  }
  if (effect == 62) {
    Serial.println(F("62 − Transition Click 5 – 20%"));
  }
  if (effect == 63) {
    Serial.println(F("63 − Transition Click 6 – 10%"));
  }
  if (effect == 64) {
    Serial.println(F("64 − Transition Hum 1 – 100%"));
  }
  if (effect == 65) {
    Serial.println(F("65 − Transition Hum 2 – 80%"));
  }
  if (effect == 66) {
    Serial.println(F("66 − Transition Hum 3 – 60%"));
  }
  if (effect == 67) {
    Serial.println(F("67 − Transition Hum 4 – 40%"));
  }
  if (effect == 68) {
    Serial.println(F("68 − Transition Hum 5 – 20%"));
  }
  if (effect == 69) {
    Serial.println(F("69 − Transition Hum 6 – 10%"));
  }
  if (effect == 70) {
    Serial.println(F("70 − Transition Ramp Down Long Smooth 1 – 100 to 0%"));
  }
  if (effect == 71) {
    Serial.println(F("71 − Transition Ramp Down Long Smooth 2 – 100 to 0%"));
  }
  if (effect == 72) {
    Serial.println(F("72 − Transition Ramp Down Medium Smooth 1 – 100 to 0%"));
  }
  if (effect == 73) {
    Serial.println(F("73 − Transition Ramp Down Medium Smooth 2 – 100 to 0%"));
  }
  if (effect == 74) {
    Serial.println(F("74 − Transition Ramp Down Short Smooth 1 – 100 to 0%"));
  }
  if (effect == 75) {
    Serial.println(F("75 − Transition Ramp Down Short Smooth 2 – 100 to 0%"));
  }
  if (effect == 76) {
    Serial.println(F("76 − Transition Ramp Down Long Sharp 1 – 100 to 0%"));
  }
  if (effect == 77) {
    Serial.println(F("77 − Transition Ramp Down Long Sharp 2 – 100 to 0%"));
  }
  if (effect == 78) {
    Serial.println(F("78 − Transition Ramp Down Medium Sharp 1 – 100 to 0%"));
  }
  if (effect == 79) {
    Serial.println(F("79 − Transition Ramp Down Medium Sharp 2 – 100 to 0%"));
  }
  if (effect == 80) {
    Serial.println(F("80 − Transition Ramp Down Short Sharp 1 – 100 to 0%"));
  }
  if (effect == 81) {
    Serial.println(F("81 − Transition Ramp Down Short Sharp 2 – 100 to 0%"));
  }
  if (effect == 82) {
    Serial.println(F("82 − Transition Ramp Up Long Smooth 1 – 0 to 100%"));
  }
  if (effect == 83) {
    Serial.println(F("83 − Transition Ramp Up Long Smooth 2 – 0 to 100%"));
  }
  if (effect == 84) {
    Serial.println(F("84 − Transition Ramp Up Medium Smooth 1 – 0 to 100%"));
  }
  if (effect == 85) {
    Serial.println(F("85 − Transition Ramp Up Medium Smooth 2 – 0 to 100%"));
  }
  if (effect == 86) {
    Serial.println(F("86 − Transition Ramp Up Short Smooth 1 – 0 to 100%"));
  }
  if (effect == 87) {
    Serial.println(F("87 − Transition Ramp Up Short Smooth 2 – 0 to 100%"));
  }
  if (effect == 88) {
    Serial.println(F("88 − Transition Ramp Up Long Sharp 1 – 0 to 100%"));
  }
  if (effect == 89) {
    Serial.println(F("89 − Transition Ramp Up Long Sharp 2 – 0 to 100%"));
  }
  if (effect == 90) {
    Serial.println(F("90 − Transition Ramp Up Medium Sharp 1 – 0 to 100%"));
  }
  if (effect == 91) {
    Serial.println(F("91 − Transition Ramp Up Medium Sharp 2 – 0 to 100%"));
  }
  if (effect == 92) {
    Serial.println(F("92 − Transition Ramp Up Short Sharp 1 – 0 to 100%"));
  }
  if (effect == 93) {
    Serial.println(F("93 − Transition Ramp Up Short Sharp 2 – 0 to 100%"));
  }
  if (effect == 94) {
    Serial.println(F("94 − Transition Ramp Down Long Smooth 1 – 50 to 0%"));
  }
  if (effect == 95) {
    Serial.println(F("95 − Transition Ramp Down Long Smooth 2 – 50 to 0%"));
  }
  if (effect == 96) {
    Serial.println(F("96 − Transition Ramp Down Medium Smooth 1 – 50 to 0%"));
  }
  if (effect == 97) {
    Serial.println(F("97 − Transition Ramp Down Medium Smooth 2 – 50 to 0%"));
  }
  if (effect == 98) {
    Serial.println(F("98 − Transition Ramp Down Short Smooth 1 – 50 to 0%"));
  }
  if (effect == 99) {
    Serial.println(F("99 − Transition Ramp Down Short Smooth 2 – 50 to 0%"));
  }
  if (effect == 100) {
    Serial.println(F("100 − Transition Ramp Down Long Sharp 1 – 50 to 0%"));
  }
  if (effect == 101) {
    Serial.println(F("101 − Transition Ramp Down Long Sharp 2 – 50 to 0%"));
  }
  if (effect == 102) {
    Serial.println(F("102 − Transition Ramp Down Medium Sharp 1 – 50 to 0%"));
  }
  if (effect == 103) {
    Serial.println(F("103 − Transition Ramp Down Medium Sharp 2 – 50 to 0%"));
  }
  if (effect == 104) {
    Serial.println(F("104 − Transition Ramp Down Short Sharp 1 – 50 to 0%"));
  }
  if (effect == 105) {
    Serial.println(F("105 − Transition Ramp Down Short Sharp 2 – 50 to 0%"));
  }
  if (effect == 106) {
    Serial.println(F("106 − Transition Ramp Up Long Smooth 1 – 0 to 50%"));
  }
  if (effect == 107) {
    Serial.println(F("107 − Transition Ramp Up Long Smooth 2 – 0 to 50%"));
  }
  if (effect == 108) {
    Serial.println(F("108 − Transition Ramp Up Medium Smooth 1 – 0 to 50%"));
  }
  if (effect == 109) {
    Serial.println(F("109 − Transition Ramp Up Medium Smooth 2 – 0 to 50%"));
  }
  if (effect == 110) {
    Serial.println(F("110 − Transition Ramp Up Short Smooth 1 – 0 to 50%"));
  }
  if (effect == 111) {
    Serial.println(F("111 − Transition Ramp Up Short Smooth 2 – 0 to 50%"));
  }
  if (effect == 112) {
    Serial.println(F("112 − Transition Ramp Up Long Sharp 1 – 0 to 50%"));
  }
  if (effect == 113) {
    Serial.println(F("113 − Transition Ramp Up Long Sharp 2 – 0 to 50%"));
  }
  if (effect == 114) {
    Serial.println(F("114 − Transition Ramp Up Medium Sharp 1 – 0 to 50%"));
  }
  if (effect == 115) {
    Serial.println(F("115 − Transition Ramp Up Medium Sharp 2 – 0 to 50%"));
  }
  if (effect == 116) {
    Serial.println(F("116 − Transition Ramp Up Short Sharp 1 – 0 to 50%"));
  }
  if (effect == 117) {
    Serial.println(F("117 − Transition Ramp Up Short Sharp 2 – 0 to 50%"));
  }
  if (effect == 118) {
    Serial.println(F("118 − Long buzz for programmatic stopping – 100%"));
  }
  if (effect == 119) {
    Serial.println(F("119 − Smooth Hum 1 (No kick or brake pulse) – 50%"));
  }
  if (effect == 120) {
    Serial.println(F("120 − Smooth Hum 2 (No kick or brake pulse) – 40%"));
  }
  if (effect == 121) {
    Serial.println(F("121 − Smooth Hum 3 (No kick or brake pulse) – 30%"));
  }
  if (effect == 122) {
    Serial.println(F("122 − Smooth Hum 4 (No kick or brake pulse) – 20%"));
  }
  if (effect == 123) {
    Serial.println(F("123 − Smooth Hum 5 (No kick or brake pulse) – 10%"));
  }

  // set the effect to play
  drv.setWaveform(0, effect);  // play effect
  //drv.setWaveform(1, effect+1);       // end waveform
  drv.setWaveform(1, 0);

  // play the effect!

  drv.go();
//  Serial.print("Status: ");
//  Serial.println(drv.readRegister8(DRV2605_REG_STATUS));
//  Serial.print("Rated-volt: ");
//  Serial.println(drv.readRegister8(DRV2605_REG_RATEDV));
//  Serial.print("Seq1: ");
//  Serial.println(drv.readRegister8(DRV2605_REG_WAVESEQ1));

  Serial.print("Lib: ");
  Serial.println(drv.readRegister8(DRV2605_REG_LIBRARY));


  // wait a bit
  delay(30000);
  Serial.println(drv.readRegister8(DRV2605_REG_GO));
  drv.stop();

  effect++;
  if (effect > 117) effect = 1;
}
And here is the output of my console:

Code: Select all


ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x438
load:0x403ce000,len:0x918
load:0x403d0000,len:0x24e4
SHA-256 comparison failed:
Calculated: 080c5cb68a075ced55f248b97bca965e3e5bd5da80a64e34e6a1638f89d6f64e
Expected: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Attempting to boot anyway...
entry 0x403ce000

I2C scanner. Scanning ...
Found address: 90 (0x5A)
Done.
Found 1 device(s).
Adafruit DRV2605 Basic test
Status... read: 0xCC
(0x1)  write: 0x80  (10000000)    |   read: 0x40  (1000000)    <------------- did not work!! 

Resetting...
Resetting...

Chip registers reset to default values...

sweep through all registries and print values...
Reg 0x0 |   HEX: 0xC0 |   bits: 11000000
Reg 0x1 |   HEX: 0x40 |   bits: 1000000
Reg 0x2 |   HEX: 0x0 |   bits: 0
Reg 0x3 |   HEX: 0x0 |   bits: 0
Reg 0x4 |   HEX: 0x1 |   bits: 1
Reg 0x5 |   HEX: 0x0 |   bits: 0
Reg 0x6 |   HEX: 0x0 |   bits: 0
Reg 0x7 |   HEX: 0x0 |   bits: 0
Reg 0x8 |   HEX: 0x0 |   bits: 0
Reg 0x9 |   HEX: 0x0 |   bits: 0
Reg 0xA |   HEX: 0x0 |   bits: 0
Reg 0xB |   HEX: 0x0 |   bits: 0
Reg 0xC |   HEX: 0x0 |   bits: 0
Reg 0xD |   HEX: 0x0 |   bits: 0
Reg 0xE |   HEX: 0x0 |   bits: 0
Reg 0xF |   HEX: 0x0 |   bits: 0
Reg 0x10 |   HEX: 0x0 |   bits: 0
Reg 0x11 |   HEX: 0x5 |   bits: 101
Reg 0x12 |   HEX: 0x19 |   bits: 11001
Reg 0x13 |   HEX: 0xFF |   bits: 11111111
Reg 0x14 |   HEX: 0x19 |   bits: 11001
Reg 0x15 |   HEX: 0xFF |   bits: 11111111
Reg 0x16 |   HEX: 0x3E |   bits: 111110
Reg 0x17 |   HEX: 0x9B |   bits: 10011011
Reg 0x18 |   HEX: 0xC |   bits: 1100
Reg 0x19 |   HEX: 0x6F |   bits: 1101111
Reg 0x1A |   HEX: 0x36 |   bits: 110110
Reg 0x1B |   HEX: 0x93 |   bits: 10010011
Reg 0x1C |   HEX: 0xF5 |   bits: 11110101
Reg 0x1D |   HEX: 0x80 |   bits: 10000000
Reg 0x1E |   HEX: 0x20 |   bits: 100000
Reg 0x1F |   HEX: 0x80 |   bits: 10000000
Reg 0x20 |   HEX: 0x33 |   bits: 110011
Reg 0x21 |   HEX: 0x95 |   bits: 10010101
Reg 0x22 |   HEX: 0x0 |   bits: 0
(0x3)  write: 0x80  (10000000)    |   read: 0x80  (10000000) 
(0x3)  write: 0x40  (1000000)    |   read: 0x40  (1000000) 
(0x3)  write: 0x20  (100000)    |   read: 0x20  (100000) 
(0x3)  write: 0x10  (10000)    |   read: 0x10  (10000) 
(0x3)  write: 0x8  (1000)    |   read: 0x8  (1000) 
(0x3)  write: 0x4  (100)    |   read: 0x0  (0)    <------------- did not work!! 

(0x3)  write: 0x2  (10)    |   read: 0x0  (0)    <------------- did not work!! 

(0x3)  write: 0x1  (1)    |   read: 0x0  (0)    <------------- did not work!! 

(0x3)  write: 0x3  (11)    |   read: 0x0  (0)    <------------- did not work!! 

(0x3)  write: 0x7  (111)    |   read: 0x0  (0)    <------------- did not work!! 

(0x3)  write: 0x6  (110)    |   read: 0x0  (0)    <------------- did not work!! 

(0x3)  write: 0x81  (10000001)    |   read: 0x80  (10000000)    <------------- did not work!! 

(0x3)  write: 0x82  (10000010)    |   read: 0x80  (10000000)    <------------- did not work!! 

(0x3)  write: 0x0  (0)    |   read: 0x0  (0) 
(0x3)  write: 0x6  (110)    |   read: 0x0  (0)    <------------- did not work!! 

(0x3)  write: 0xA0  (10100000)    |   read: 0xA0  (10100000) 
(0x3)  write: 0x6  (110)    |   read: 0x0  (0)    <------------- did not work!! 

(0x3)  write: 0xD7  (11010111)    |   read: 0xD0  (11010000)    <------------- did not work!! 

(0x3)  write: 0xAF  (10101111)    |   read: 0xA8  (10101000)    <------------- did not work!! 

(0x16)  write: 0x50  (1010000)    |   read: 0x50  (1010000) 
voltage_set
(0x17)  write: 0x89  (10001001)    |   read: 0x89  (10001001) 
overvoltage
(0x1A)  write: 0xB6  (10110110)    |   read: 0xB6  (10110110) 
feedback
(0x1B)  write: 0x93  (10010011)    |   read: 0x93  (10010011) 
contol1
(0x1C)  write: 0xF5  (11110101)    |   read: 0xF5  (11110101) 
contol2
(0x1D)  write: 0x80  (10000000)    |   read: 0x80  (10000000) 
control3
(0x1)  write: 0x7  (111)    |   read: 0x7  (111) 
autoCalibrationMode
(0x1E)  write: 0x20  (100000)    |   read: 0x20  (100000) 
control4
(0xC)  write: 0x1  (1)    |   read: 0x1  (1) 
GO Autocalibration... !
STATUS_Reg: 0x1
DRV2605 Auto-calibration complete
Auto-Calibration Compensation Result: 0xC
Auto-Calibration Back-EMF Result: 0x6F
Feedback Control: 0xB6
Analog gain of the back-EMF amplifier: 20x
standby-mode off 
(0x1)  write: 0x0  (0)    |   read: 0x0  (0) 
voltage_set  
(0x16)  write: 0x53  (1010011)    |   read: 0x53  (1010011) 
overvoltage  
(0x17)  write: 0x89  (10001001)    |   read: 0x89  (10001001) 
feedback  
(0x1A)  write: 0xB6  (10110110)    |   read: 0xB6  (10110110) 
contol1 
(0x1B)  write: 0x13  (10011)    |   read: 0x13  (10011) 
contol2  
(0x1C)  write: 0xF5  (11110101)    |   read: 0xF5  (11110101) 
control3  
(0x1D)  write: 0x80  (10000000)    |   read: 0x80  (10000000) 
Lib select  
(0x3)  write: 0x6  (110)    |   read: 0x0  (0)    <------------- did not work!! 

active mode  
(0x1)  write: 0x0  (0)    |   read: 0x0  (0) 
sweep through all registries and print values...
Reg 0x0 |   HEX: 0xCC |   bits: 11001100
Reg 0x1 |   HEX: 0x0 |   bits: 0
Reg 0x2 |   HEX: 0x0 |   bits: 0
Reg 0x3 |   HEX: 0x0 |   bits: 0
Reg 0x4 |   HEX: 0x1 |   bits: 1
Reg 0x5 |   HEX: 0x0 |   bits: 0
Reg 0x6 |   HEX: 0x0 |   bits: 0
Reg 0x7 |   HEX: 0x0 |   bits: 0
Reg 0x8 |   HEX: 0x0 |   bits: 0
Reg 0x9 |   HEX: 0x0 |   bits: 0
Reg 0xA |   HEX: 0x0 |   bits: 0
Reg 0xB |   HEX: 0x0 |   bits: 0
Reg 0xC |   HEX: 0x0 |   bits: 0
Reg 0xD |   HEX: 0x0 |   bits: 0
Reg 0xE |   HEX: 0x0 |   bits: 0
Reg 0xF |   HEX: 0x0 |   bits: 0
Reg 0x10 |   HEX: 0x0 |   bits: 0
Reg 0x11 |   HEX: 0x5 |   bits: 101
Reg 0x12 |   HEX: 0x19 |   bits: 11001
Reg 0x13 |   HEX: 0xFF |   bits: 11111111
Reg 0x14 |   HEX: 0x19 |   bits: 11001
Reg 0x15 |   HEX: 0xFF |   bits: 11111111
Reg 0x16 |   HEX: 0x53 |   bits: 1010011
Reg 0x17 |   HEX: 0x89 |   bits: 10001001
Reg 0x18 |   HEX: 0xC |   bits: 1100
Reg 0x19 |   HEX: 0x6F |   bits: 1101111
Reg 0x1A |   HEX: 0xB6 |   bits: 10110110
Reg 0x1B |   HEX: 0x13 |   bits: 10011
Reg 0x1C |   HEX: 0xF5 |   bits: 11110101
Reg 0x1D |   HEX: 0x80 |   bits: 10000000
Reg 0x1E |   HEX: 0x20 |   bits: 100000
Reg 0x1F |   HEX: 0x80 |   bits: 10000000
Reg 0x20 |   HEX: 0x33 |   bits: 110011
Reg 0x21 |   HEX: 0x95 |   bits: 10010101
Reg 0x22 |   HEX: 0x0 |   bits: 0
(0x16)  write: 0x50  (1010000)    |   read: 0x50  (1010000) 
voltage_set
(0x17)  write: 0x89  (10001001)    |   read: 0x89  (10001001) 
overvoltage
(0x1A)  write: 0xB6  (10110110)    |   read: 0xB6  (10110110) 
feedback
(0x1B)  write: 0x93  (10010011)    |   read: 0x93  (10010011) 
contol1
(0x1C)  write: 0xF5  (11110101)    |   read: 0xF5  (11110101) 
contol2
(0x1D)  write: 0x80  (10000000)    |   read: 0x80  (10000000) 
control3
(0x1)  write: 0x7  (111)    |   read: 0x7  (111) 
autoCalibrationMode
(0x1E)  write: 0x20  (100000)    |   read: 0x20  (100000) 
control4
(0xC)  write: 0x1  (1)    |   read: 0x1  (1) 
GO Autocalibration... !
STATUS_Reg: 0x1
DRV2605 Auto-calibration complete
Auto-Calibration Compensation Result: 0xC
Auto-Calibration Back-EMF Result: 0x6F
Feedback Control: 0xB6
Analog gain of the back-EMF amplifier: 20x
sweep through all registries and print values...
Reg 0x0 |   HEX: 0xC4 |   bits: 11000100
Reg 0x1 |   HEX: 0x7 |   bits: 111
Reg 0x2 |   HEX: 0x0 |   bits: 0
Reg 0x3 |   HEX: 0x0 |   bits: 0
Reg 0x4 |   HEX: 0x1 |   bits: 1
Reg 0x5 |   HEX: 0x0 |   bits: 0
Reg 0x6 |   HEX: 0x0 |   bits: 0
Reg 0x7 |   HEX: 0x0 |   bits: 0
Reg 0x8 |   HEX: 0x0 |   bits: 0
Reg 0x9 |   HEX: 0x0 |   bits: 0
Reg 0xA |   HEX: 0x0 |   bits: 0
Reg 0xB |   HEX: 0x0 |   bits: 0
Reg 0xC |   HEX: 0x1 |   bits: 1
Reg 0xD |   HEX: 0x0 |   bits: 0
Reg 0xE |   HEX: 0x0 |   bits: 0
Reg 0xF |   HEX: 0x0 |   bits: 0
Reg 0x10 |   HEX: 0x0 |   bits: 0
Reg 0x11 |   HEX: 0x5 |   bits: 101
Reg 0x12 |   HEX: 0x19 |   bits: 11001
Reg 0x13 |   HEX: 0xFF |   bits: 11111111
Reg 0x14 |   HEX: 0x19 |   bits: 11001
Reg 0x15 |   HEX: 0xFF |   bits: 11111111
Reg 0x16 |   HEX: 0x50 |   bits: 1010000
Reg 0x17 |   HEX: 0x89 |   bits: 10001001
Reg 0x18 |   HEX: 0xC |   bits: 1100
Reg 0x19 |   HEX: 0x6F |   bits: 1101111
Reg 0x1A |   HEX: 0xB6 |   bits: 10110110
Reg 0x1B |   HEX: 0x93 |   bits: 10010011
Reg 0x1C |   HEX: 0xF5 |   bits: 11110101
Reg 0x1D |   HEX: 0x80 |   bits: 10000000
Reg 0x1E |   HEX: 0x20 |   bits: 100000
Reg 0x1F |   HEX: 0x80 |   bits: 10000000
Reg 0x20 |   HEX: 0x33 |   bits: 110011
Reg 0x21 |   HEX: 0x95 |   bits: 10010101
Reg 0x22 |   HEX: 0x0 |   bits: 0
11.2 Waveform Library Effects List
1 − Strong Click - 100%
(0x4)  write: 0x1  (1)    |   read: 0x1  (1) 
(0x5)  write: 0x0  (0)    |   read: 0x0  (0) 
(0xC)  write: 0x1  (1)    |   read: 0x1  (1) 
Lib: 0
Lots of information, I hope someone can take a look if they find the problem since I am stuck..
Thanks a lot and best regards,
Marcus

User avatar
adafruit_support_carter
 
Posts: 24423
Joined: Tue Nov 29, 2016 2:45 pm

Re: DRV2605L problem: cannot write/read register LIBRARY_SEL

Post by adafruit_support_carter »

I tried the standard adafruit library but without success
What did not work?

User avatar
MarcusHS
 
Posts: 6
Joined: Tue Aug 16, 2022 12:05 pm

Re: DRV2605L problem: cannot write/read register LIBRARY_SEL

Post by MarcusHS »

What did not work?
I couldn't (and still can't) select a waveform-library (1: Library A, ... , 6: LRA-Library) to use, so I made some changes trying to debug the problem, but didn't find the problem yet.. I can try to use the standard library again and do all the editing/debugging in the arduino-ide and report back, that probably makes it a lot easier for you to help me?

I'm new to all this and found it easier (for debugging) to edit the library and insert (for example) "Serial.print" commands to the functions, rather than doing so repeatedly inside the arduino ide..

Can someone confirm that they are able to write the lib-select bits of reg address 0x03 and then read back the correct value of the register? I have a feeling that the writing works but I might not be able to read these bits even though the datasheet says so?
Also, does anyone know what the reserved bits in this register are used for?

Looking at the datasheet, the standard value of this register is supposed to be 0x01 after power cycling the chip (meaning all reserved bits are 0 and library 1 is selected by default) but in my case I read 0x00 after startup so in my case library 0 (an empty Library) is selected by default. ?

User avatar
adafruit_support_carter
 
Posts: 24423
Joined: Tue Nov 29, 2016 2:45 pm

Re: DRV2605L problem: cannot write/read register LIBRARY_SEL

Post by adafruit_support_carter »

The Arduino library:
https://github.com/adafruit/Adafruit_DRV2605_Library
takes care of the register writing.

The selectLibrary() method is used to select a waveform library:
https://adafruit.github.io/Adafruit_DRV ... a2d3cc4123

Also linking guide for general reference:
https://learn.adafruit.com/adafruit-drv ... r-breakout

User avatar
MarcusHS
 
Posts: 6
Joined: Tue Aug 16, 2022 12:05 pm

Re: DRV2605L problem: cannot write/read register LIBRARY_SEL

Post by MarcusHS »

adafruit_support_carter wrote: Wed Aug 17, 2022 4:20 pm The Arduino library:
https://github.com/adafruit/Adafruit_DRV2605_Library
takes care of the register writing.
Seems that it is not working for the register 0x03 bits [2:0]
adafruit_support_carter wrote: Wed Aug 17, 2022 4:20 pm The selectLibrary() method is used to select a waveform library:
https://adafruit.github.io/Adafruit_DRV ... a2d3cc4123

Also linking guide for general reference:
https://learn.adafruit.com/adafruit-drv ... r-breakout
I have read all these documents before posting and yes, I understand how the library works. I also have carefully read the entire datasheet of the DRV2605..

User avatar
adafruit_support_carter
 
Posts: 24423
Joined: Tue Nov 29, 2016 2:45 pm

Re: DRV2605L problem: cannot write/read register LIBRARY_SEL

Post by adafruit_support_carter »

How is it not working? Can you provide a simple example sketch that demonstrates the issue?

User avatar
MarcusHS
 
Posts: 6
Joined: Tue Aug 16, 2022 12:05 pm

Re: DRV2605L problem: cannot write/read register LIBRARY_SEL

Post by MarcusHS »

ok so lets go back to the original library:

Arduino code with unedited library:

Code: Select all

#include <Wire.h>
#include "Adafruit_DRV2605.h"

Adafruit_DRV2605 drv;

TwoWire I2C_DRV = TwoWire(0);
uint8_t read_val;
uint8_t write_val;

void setup() {

  //I2C on pins 5,6
  I2C_DRV.begin(5, 6);



  Serial.begin(115200);
  Serial.println("Adafruit DRV2605 Basic test");
  Serial.println("");
  if (! drv.begin(&I2C_DRV)) {
    Serial.println("Could not find DRV2605");
    while (1) delay(10);
  }



  // first try: select library 1
  //Write via .selectLibrary(1) command:
  drv.selectLibrary(1);
  Serial.println("Write via .selectLibrary(1) command");
  read_val = drv.readRegister8(DRV2605_REG_LIBRARY);
  Serial.print("READ DRV2605_REG_LIBRARY:    value in..  HEX:");
  Serial.print(read_val, HEX);
  Serial.print(" BIN: ");
  Serial.println(read_val, BIN);
  Serial.println("");

  // second try: select library 6
  //Write via .selectLibrary(6) command:
  drv.selectLibrary(6);
  Serial.println("Write via .selectLibrary(6) command");
  read_val = drv.readRegister8(DRV2605_REG_LIBRARY);
  Serial.print("READ DRV2605_REG_LIBRARY:    value in..  HEX:");
  Serial.print(read_val, HEX);
  Serial.print(" BIN: ");
  Serial.println(read_val, BIN);
  Serial.println("");


  //third try:
  //Write via .writeRegister8(reg, val) command:
  write_val = 0x06;
  drv.writeRegister8(0x03, write_val);
  Serial.print("WRITE to REG 0x03..  written value in..  HEX:");
  Serial.print(write_val, HEX);
  Serial.print("  BIN: ");
  Serial.println(write_val, BIN);

  read_val = drv.readRegister8(0x03);
  Serial.print("READ REG 0x03:    value in..  HEX:");
  Serial.print(read_val, HEX);
  Serial.print("  BIN: ");
  Serial.println(read_val, BIN);
  Serial.println("");




  //reference to show that the commands generally do work:
  write_val = 0xA8;
  drv.writeRegister8(0x03, write_val);
  Serial.print("WRITE to REG 0x03..  written value in..  HEX:");
  Serial.print(write_val, HEX);
  Serial.print("  BIN: ");
  Serial.println(write_val, BIN);

  read_val = drv.readRegister8(0x03);
  Serial.print("READ REG 0x03:    value in..  HEX:");
  Serial.print(read_val, HEX);
  Serial.print("  BIN: ");
  Serial.println(read_val, BIN);
  Serial.println("");


  // I2C trigger by sending 'go' command
  // default, internal trigger when sending GO command
  drv.setMode(DRV2605_MODE_INTTRIG);
}

uint8_t effect = 1;

void loop() {
  //
  // set the effect to play
  drv.setWaveform(0, effect);  // play effect
  drv.setWaveform(1, 0);       // end waveform

  // play the effect!
  drv.go();
  Serial.println("go");

  // wait a bit
  delay(2000);
}
console output:

Code: Select all

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x438
load:0x403ce000,len:0x918
load:0x403d0000,len:0x24e4
SHA-256 comparison failed:
Calculated: 080c5cb68a075ced55f248b97bca965e3e5bd5da80a64e34e6a1638f89d6f64e
Expected: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Attempting to boot anyway...
entry 0x403ce000
Adafruit DRV2605 Basic test

Write via .selectLibrary(1) command
READ DRV2605_REG_LIBRARY:    value in..  HEX:0 BIN: 0

Write via .selectLibrary(6) command
READ DRV2605_REG_LIBRARY:    value in..  HEX:0 BIN: 0

WRITE to REG 0x03..  written value in..  HEX:6  BIN: 110
READ REG 0x03:    value in..  HEX:0  BIN: 0

WRITE to REG 0x03..  written value in..  HEX:A8  BIN: 10101000
READ REG 0x03:    value in..  HEX:A8  BIN: 10101000

go
go
go
go


No errors on the write command, but I read 0x00 from the LIB Select register when trying to select libraries 1-6.. writing only works with values that have 000 as the least significant bits [2:0] (last write example - for example writing 0xA8, more examples are found in my original post)... and these bits are exactly the ones for choosing the library which the DRV2605L uses to generate the waveforms. So I always end up with library 0, which is an empty library.

User avatar
adafruit_support_carter
 
Posts: 24423
Joined: Tue Nov 29, 2016 2:45 pm

Re: DRV2605L problem: cannot write/read register LIBRARY_SEL

Post by adafruit_support_carter »

This is likely an ESP32 specific behavior.

Running your example sketch on a Qt Py M0:
https://www.adafruit.com/product/4600
produces different, and generally expected, results:

Code: Select all

Adafruit DRV2605 Basic test

Write via .selectLibrary(1) command
READ DRV2605_REG_LIBRARY:    value in..  HEX:1 BIN: 1

Write via .selectLibrary(6) command
READ DRV2605_REG_LIBRARY:    value in..  HEX:6 BIN: 110

WRITE to REG 0x03..  written value in..  HEX:6  BIN: 110
READ REG 0x03:    value in..  HEX:6  BIN: 110

WRITE to REG 0x03..  written value in..  HEX:A8  BIN: 10101000
READ REG 0x03:    value in..  HEX:AE  BIN: 10101110
The DRV2605 is expecting a repeated start for the read operation:
drv_i2c_rs.jpg
drv_i2c_rs.jpg (102.89 KiB) Viewed 43 times
There is a known limitation with ESP32 and repeated start. See here:
https://learn.adafruit.com/working-with ... ated-start
and here:
https://github.com/espressif/arduino-esp32/issues/5702

So the ESP32 is not producing the expected I2C traffic and the DRV2605 does not like that.

User avatar
MarcusHS
 
Posts: 6
Joined: Tue Aug 16, 2022 12:05 pm

Re: DRV2605L problem: cannot write/read register LIBRARY_SEL

Post by MarcusHS »

Thank you for verifying that my code is working on another device with another breakout board! This for sure helps me out a lot.
The weird thing is that I can write to any other registry and read back the written value just fine, so I think that it is not the I2C traffic causing this problem but the chip itself..
Also I tried using the DRV2605 breakout board with an Arduino Uno instead of the ESP32, same results..

So as of now, I believe I can successfully write to the registry 0x03 but somehow the bits [2:0] instantly get overwritten with zeros..
Meaning: if I power cycle my chip I read the value 0x00 from reg 0x03. Now I write for example 0xA9 into this registry (which is 10101001 in binary) and then I read this registry and get a value of 0xA8 (which is 10101000 in binary). This means that the writing was successful because the 5 most significant bits have correctly changed, but somehow the three least significant bits were set to zero again instantly after the writing.

I am starting to believe that I have gotten a faulty chip/breakout board, but since the same problem occurs on two different breakout boards I don't know... Any ideas on how to continue searching for the error?

User avatar
adafruit_support_carter
 
Posts: 24423
Joined: Tue Nov 29, 2016 2:45 pm

Re: DRV2605L problem: cannot write/read register LIBRARY_SEL

Post by adafruit_support_carter »

Do you have access to any other main boards? Other than the UNO and ESP32?

User avatar
MarcusHS
 
Posts: 6
Joined: Tue Aug 16, 2022 12:05 pm

Re: DRV2605L problem: cannot write/read register LIBRARY_SEL

Post by MarcusHS »

Hmm, I could borrow a Nano but that uses the same chip as the Uno (Atmega 328p) so I guess that would not make any difference..
What are the chances that my two boards were from a faulty batch of chips - which have a problem with writing to specific registers/bits of its RAM?
I'm thinking of getting some new DRV2605 chips and replace the ones currently on the breakout board..

Post Reply
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”