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.
if (ret != HAL_OK) { strcpy((char*)buf, "Error Tx\r\n");
What does that tell you? \$\endgroup\$