cancel
Showing results for 
Search instead for 
Did you mean: 

I2C PROBLEMS

m-a-c-f
Associate II

Hi there!

First, I need to declare my frustration with CUBE IDE complexity. My code is not for blinking a LED or test one button, but a complex code that involves an 7 inch LCD, EEPROM, TEA6686 PLL, DS3231 RTC, DS18B20 temperature sensor and so on, It is almost impossible to organize the code with so many files to manage, and now, besides of working fine at main.c file, the I2C3 is not recognize outside the main.c file. This is boring, so boring that I am hard thinking to change the processor and IDE. Tons off #includes, tons off crisscross references, we get crazy...... What the hell…..

Well, my code is to far advance, lets see how may I solve this problem…. It is the edge….

I created a file R_T_C.c and RTC.h to manage all information regarding with DS3231, but when I try to use “HAL_I2C_Mem_Write(&hi2c3, 0XD0, 0X0E, 1, 0b00000000, 1, 1000);”  it says that  'hi2c3' undeclared (first use in this function). What may I do to solve the new issue…… Already tried to #include everything, no progress….. Prity! Besides of the STM32 power, I acknowledge that, the IDE does not accomplish with this….

 

Best regards..

1 ACCEPTED SOLUTION

Accepted Solutions

You were Wright!!! Thank you! Tesla DeLorean!!

 

I deep READ the function, and add the following statements to my .c file:

 

#include <stm32f4xx_hal.h>

extern I2C_HandleTypeDef  hi2c3;

 

You know, it is quite estranged for me, that comes from old times, at MPLAB and 8 bit Microchip processors, to have to declare several times the same variable. It takes some time to adjust my brain. Now I have full control of I2c3.

 

C++ does not make my mind! 

 

Regards;

View solution in original post

3 REPLIES 3

Define the structure in one of your .C files, and as an extern in the related .H you pull into everything else.

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

Thanks!

 

Already triyed, not working! The new include I made does not " recognize "&hi2c3" that is a pointer to I2C3 handler.  

 

Regards;

You were Wright!!! Thank you! Tesla DeLorean!!

 

I deep READ the function, and add the following statements to my .c file:

 

#include <stm32f4xx_hal.h>

extern I2C_HandleTypeDef  hi2c3;

 

You know, it is quite estranged for me, that comes from old times, at MPLAB and 8 bit Microchip processors, to have to declare several times the same variable. It takes some time to adjust my brain. Now I have full control of I2c3.

 

C++ does not make my mind! 

 

Regards;