2021-06-05 10:05 AM
I have configured the GPIO for I2C1(Alternate function 4) and enabled the Clock for I2C1. After that I am trying to enable the ACK. but not able to enable that.. Also tried for I2C2 and I2C3 facing the same issue.
//enable the clock for the I2C peripheral
I2C_PeriClkControl(pI2CHandle->pI2Cx, ENABLE);
// ack control bit
uint32_t tempreg = 0;
tempreg |= (pI2CHandle->I2C_Config.I2C_AckControl << 10);
pI2CHandle->pI2Cx->I2C_CR1 |= tempreg;
I also tried manually in debug mode. Not able to SET ACK bit of CR1 register of any I2C(I2C1/I2C2/I2C3)
Any idea how to resolve this issue?
Can anyone help please
Solved! Go to Solution.
2021-06-06 07:42 AM
Read the reference manual. If PE=0, the peripheral is not enabled and will not do anything. The START and ACK bits are cleared to 0 by hardware when PE=0.
2021-06-05 01:26 PM
I2C1 is clock is enabled in RCC register
After setting the ACK in I2C1_CR1 it is not getting set
2021-06-05 02:55 PM
Did you set PE=1?
2021-06-06 12:29 AM
@TDK
No Actually I am trying to do I2C1 inits. So I am trying to set the ACK bit (Bit 10 ) in the I2C1_CR1 register so that the acknowledge will be enabled. I am not starting the communication yet. PE=1 when the communication will be started. Am I right?
2021-06-06 12:45 AM
@TDK As you said I also tried to enable PE after I2C1 init but PE and START condition are not getting enabled.
START:
PE:
Am I missing anything?
2021-06-06 07:42 AM
Read the reference manual. If PE=0, the peripheral is not enabled and will not do anything. The START and ACK bits are cleared to 0 by hardware when PE=0.
2021-06-06 09:55 AM
Thanks for helping.