I am using an STM32 NUCLEO-F042K6 dev board to interact with a MCP4451 digital pot. I want to be able to adjust the wiper values through i2c. I am using the STM32CubeIDE and the HAL library to interface.
static const uint8_t POT_ADDRESS = 0x58;
static const uint8_t INCREMENT = 0x94;
while (1) {
buf[0] = INCREMENT;
ret = HAL_I2C_Master_Transmit(&hi2c1, POT_ADDRESS, buf, 2, HAL_MAX_DELAY);
if (ret != HAL_OK) {
strcpy((char*)buf, "Error Tx\r\n");
} else {
strcpy((char*)buf, "YEET\r\n");
}
HAL_UART_Transmit(&huart2, buf, strlen((char*)buf), HAL_MAX_DELAY);
HAL_Delay(200);
}
I have the correct configuration, but I keep getting "Error Tx" on the serial monitor. I made sure to power the i2c lines with pull-up resistors to 3.3V. I'm a bit lost as to what to do.
1 Answer 1
My supervisor found the issue. The digital pot runs off of 5V, but since the i2c line runs at 3.3V, it wasn't registering digital high properly. Since the STM32 pins on my dev board are 5V, as soon as I ran everything on 5V, I got an ok status.
if (ret != HAL_OK) { strcpy((char*)buf, "Error Tx\r\n");
What does that tell you? \$\endgroup\$