Hi,
I am trying to control a digital pot via I2C, but I can't get it to work. I have added the code for initialization and transmission below. The clock for I2C channel 1 is enabled and the SCL and SDA pins are initialized as direct alternative function. The problem is that after setting the ST bit (issuing a start condition), the TDRE bit will not be set (as well as BBSY and START). Does someone have an idea about what I am doing wrong here?
Thanks in advance!
Code for initialization:
// Initial settings // Bit rate // Set interrupts // Release reset |
Code for transmitting:
bool hasError = false; // Wait for the bus to be free // Issue start condition // Wait for transmit buffer empty if (!hasError) // Wait for transmit buffer empty if (!hasError) // Wait for transmit buffer empty if (!hasError) // Wait for data transmitted // Reset stop detection flag // Issue stop condition // Wait for stopped // Reset registers |