Tool/software:
I am trying to write basic arduino code to start up drv8234. The A0 and A1 are grounded and IN1 and IN2 are HIGH. The SDA and SCL of esp32 are connected with the SDA and SCL of the driver. I have a DRV8234 RTE driver. Can someone guide me with what am I doing wrong here.
I am just trying to move the motor, nothing else
Following is my code:
#include <Wire.h>
uint8_t write_address = 0b1100000, CONFIG4_REG=0x0D;
uint8_t config4_value = 0b00000111; // PMODE = 0 (EN/PH Mode), I2C_BC = 1
int in1 = 13, in2 = 12;
void setup() {
Serial.begin(115200);
Serial.println("\nI2C Scanner");
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
digitalWrite(in1, HIGH);
digitalWrite(in2, HIGH);
Wire.begin();
configureDRV8234();
}
void loop() {
}
void configureDRV8234() {
// Step 1: Enable I2C_BC in CONFIG4 Register
writeRegister(CONFIG4_REG, config4_value);
Serial.println("DRV8234 configured for EN/PH mode");
}
// Function to write to a register via I2C
void writeRegister(uint8_t reg, uint8_t value) {
Wire.beginTransmission(write_address);
delay(100);
Serial.println(Wire.write(reg)); // Register address
delay(100);
Serial.println(Wire.write(value)); // Data to write
delay(100);
Wire.endTransmission(false);
}