cancel
Showing results for 
Search instead for 
Did you mean: 

Enabling SDA and SCL pins in the Nucleo board for I2C communication.

MC.4
Associate II

Hello, I have written a code for I2C to act between two Nucleo boards, however, at the moment, the master board is not even giving me a signal output. I looked at the output using a Saleae Logic Analyzer and there isn't even a clock signal comin out of the SCL pin of the Master board, even though I have Pull-Up resistors.

With that in mind, is there anything in special a beginner like me should look at such as connections or initializations in the code? I am using mostly the HAL_I2C functions.

6 REPLIES 6
KnarfB
Principal III

start with of the many tutorials like https://www.digikey.de/en/maker/projects/getting-started-with-stm32-i2c-example/ba8c2bfef2024654b5dd10012425fa23

and post more details about what you have done, chips/boards etc..

There are also complete board to board I2C examples coming with the firmware

hth

KnarfB

Start with the pins and clocks.

You don't mention a specific chip, or board variant.

Watch for things like SB (solder bridge, jumper like) connections on various boards for chip pins vs those as the Arduino or Morpho header pins.

I2C pins would need pull-ups, perhaps 2K7 external, if not available use the 10K internals

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Missing pullups?

JW​

MC.4
Associate II

I apologize for the lack of details. I am using a Nucleo G071RB board for both my Master and Slave boards. I posted my code in another post, but will include some specificities here.

Regarding the tutorial link posted, I had seen it, and when I try mimicking what he and many others did on their code I still fail to see an output on the SCL or SDA lines. That led me to think that I maybe initialized something wrong.

When considered I initialized things wrong, I took a look at my pin configuration in MX which I used to build my code's skeleton, and I tried creating my code with both GPIO Pull-up enabled and disabled as well as pairing it with external 5.6k resistors.

In my main, I have everything seen below before the control loop and the HAL_I2C_IsDeviceReady returns HAL_ERROR.

int main(void)

{

 uint8_t buffer[3];

 HAL_StatusTypeDef ret;

 HAL_Init();

 /* Configure the system clock */

 SystemClock_Config();

 /* Initialize all configured peripherals */

 MX_GPIO_Init();

 MX_I2C1_Init();

 MX_USART2_UART_Init();

 HAL_I2C_Init(&hi2c1);

 HAL_I2C_MspInit(&hi2c1);

 ret = HAL_I2C_IsDeviceReady(&hi2c1, (peripheralNucleoAddress), 10, HAL_MAX_DELAY);

 if (ret != HAL_OK)

 {

 uint8_t message[27];

   strcpy((char*) message, "Connection to board lost\n");

   HAL_UART_Transmit(&huart2, message, strlen((char*) message), 5000);

 //Transfer error in reception process

   Error_Handler();

 }

 /* USER CODE END 2 */

 /* Infinite loop */

 /* USER CODE BEGIN WHILE */

 while (1)

.

.

.

If you could send me the link to some I2C board to board connection codes I would be grateful.

Piranha
Chief II

First, for I2C you need pull-up resistors.