cancel
Showing results for 
Search instead for 
Did you mean: 

I2C1 ACK is not getting enabled in stm32f446re

PK
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

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.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

6 REPLIES 6
PK
Associate II

I2C1 is clock is enabled in RCC register

0693W00000BaCFnQAN.pngAfter setting the ACK in I2C1_CR1 it is not getting set

0693W00000BaCFiQAN.png

TDK
Guru

Did you set PE=1?

If you feel a post has answered your question, please click "Accept as Solution".
PK
Associate II

@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?

PK
Associate II

@TDK​ As you said I also tried to enable PE after I2C1 init but PE and START condition are not getting enabled.

START:

0693W00000BaCb0QAF.pngPE:

0693W00000BaCbFQAV.pngAm I missing anything?

TDK
Guru

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.

If you feel a post has answered your question, please click "Accept as Solution".
PK
Associate II

Thanks for helping.