Skip to main content
Associate III
November 22, 2023
Question

I2C error in sending data (for the oscilloscope)

  • November 22, 2023
  • 10 replies
  • 6131 views

Hello ! 

I've got a problem because I tried to check the SDA and SCL pins like in the picture : 

Xenon02_0-1700670192061.png

 


Sorry for the paint picture (the oscilloscope was during classes so I don't have it right now).
The output was all the time noises even thought the code was correct. 

 uint8_t data = 0;
 /* Infinite loop */
 /* USER CODE BEGIN WHILE */
 while (1)
 {

	 HAL_I2C_Master_Transmit(&hi2c3, 0xA0, &data, 1, 100);
	 
 /* USER CODE END WHILE */

 /* USER CODE BEGIN 3 */
 }
 /* USER CODE END 3 */
}


I've had this error : 

Xenon02_1-1700670341278.png

I don't know if this Timeout is because the I2C didn't receive the ACK bit ? 

But when I've added the pull up resistors : 

Xenon02_2-1700670423029.png

The error was then this part : 

Xenon02_3-1700670458974.png



I don't really much know what happened though. 
Maybe if I want to check the I2C in oscilloscope I have to connect an I2C slave ? 
But I don't understand why I had 2 different errors. 

In RM for STM32 Nucleo-L073RZ I found this : 

Xenon02_4-1700670585480.png

I don't know if I2C_RXDR is the ACK bit that Master is now an input and waits for this ACK/I2C_RXDR ? Maybe but this stretch was maybe a timeout ? 

I got a bit confused. Is master receiving more data through SDA (or maybe SLC although it is only a clock), not just only Start, Stop, ACK and data ? 

Also the Transmission is different because it stretches the clock after ACK and Receiver before ACK, weird, somebody knows why ? 

Thanks ! 

This topic has been closed for replies.

10 replies

Tesla DeLorean
Guru
November 22, 2023

Without pull-ups externally or within the GPIO, and OD (Open Drain) pin is never going to get above zero, it's just float or get clamped at zero.

Not sure if the STM32 observes if the pin goes high/low as it drives, but might as a means to tell if the bus is working.

If there is no Slave to respond to it's own address, going to fail at that stage.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Xenon02Author
Associate III
November 22, 2023

So I need to add OD ? 
Because it's all connected to the Oscilloscope. But didn't understand what those 2 errors means, one without pull up and one with pull up. Because it doesn't want to finish this mem_write command hence the while doesn't continue to repeat. I'm trying to figure it out because it is possible as I've heard to see the transmission from the oscilloscope but it didn't work in my case and the code is stuck.

I don't know if I can do this type of sending to the Oscilloscope directly. 

David Littell
Senior II
November 22, 2023

The I2C pins must be configured as open-drain.

The pullup resistors are required.

Of course you can use the scope to observe the signals if it's set up properly.

Xenon02Author
Associate III
November 22, 2023

As I check in CubeIDE, the I2C pins were open-drains, and the pull up resistors were also added, but the final result was that it always showed error and could return from HAL_I2C_Master_Transmit/HAL_I2C_Mem_Write. The output was also noises. Couldn't get both clear signals from SCL and SDA. 

And I wondered what those 2 error could mean then. And if I set up to see the signals I understand it will always pop out error because there is no ACK bit ? 

MM..1
Super User
November 22, 2023

Paint pictures is ok , but is GND scope and board connected ? Is pullups value ??? Is to nucleo 3,3V usw...