cancel
Showing results for 
Search instead for 
Did you mean: 

I2C is not sending a repeated start

RSolo.1
Associate II

Hello. I encountered a problem. I have an STM32F103C8T6 controller and I am trying to implement I2C communication using interrupts. The problem is that when I need to send a repeated start, it doesn't happen. ITBUFEN interrupts are disabled, I only use ITEVFEN interrupts. The sequence is as follows: Start - send address - send register address (to read from) - send repeated start. (The dashes represent entry into an interrupt). So, after sending the second start, nothing happens. However, if I read DR before sending the repeated start, it will be sent.

(void)I2C2->DR;
I2C2->CR1|=I2C_CR1_START;

Yes, there is another option. After setting the start condition, you can write some garbage data to the DR register, and then the start condition will occur. The garbage data will not be transmitted.

I2C2->CR1|=I2C_CR1_START;
I2C2->DR=0x55;

There is another option: when I send the last byte of the register address, if I immediately write a start, and then when I enter the interrupt to send the start and send it again, the start is sent. What could be the problem? What am I doing wrong? It feels like some flag is not being reset, which prevents the start from being sent. However, I checked with a debugger at that moment and did not see anything like that. I also tried to add a pause between sending the repeated start, but it did not help. The interrupt for sending the start is executed, but the start is not generated.

2 REPLIES 2
AScha.3
Chief II

i am using HAL, the HAL_I2C_Mem_Read_IT() is doing this.

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

I understand. but the problem is that it doesn't work for me.