2024-09-27 01:40 AM
Hi, I've been trying to get an i2c connection working between two nucleo boards however nothing i have tried has worked. i am using the NUCLEO-H755ZI-Q and the NUCLEO-H723ZG both with i2c1 and on the same pins pb8(scl) and pb9(sba). for the H755 dual core I have the i2c on the M4 both for initiation and using the interface. None of the clock settings have been changed and should work with the schematics and the config settings in the mx file are identical. I did remove several SB jumpers on each board however they were to free up pins from the usb and ethernet ports and other i2c devices have worked it the ports since. I tried using a logic analyzer to see what was happening and it does not look right but I'm still not sure what is happening. the i2c master transmit uses HAL_I2C_IsDeviceReady and gets HAL_OK as a return, the first bit is received but the other two are not and this always returns with HAL_ERROR both by the transmit and slave receive functions.
So far i have tried:
External Pull up resistors
Different combinations of other i2cs on the boards
increasing the GPIO output speeds and using internal pull ups
changing the i2c adress on the slave and master(now set to 0x00)
//H755 master transmit
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_I2C1_Init();
MX_I2C4_Init();
MX_I2C2_Init();
/* USER CODE BEGIN 2 */
MX_USART3_UART_Init();
HAL_I2C_Init(&hi2c1);
HAL_Delay(1000);
char txt[50];
sprintf(txt,"uart Works for i2c\r\n");
HAL_UART_Transmit(&huart3,(uint8_t*)txt,strlen(txt),1000);
HAL_Delay(4000);
HAL_StatusTypeDef RET0 = HAL_I2C_IsDeviceReady(&hi2c1, 0x00, 5, 1000);
sprintf(txt,"i2c is %d\r\n",RET0);
HAL_UART_Transmit(&huart3,(uint8_t*)txt,strlen(txt),1000);
uint8_t TxD[3] = {65,35,69};
// HAL_StatusTypeDef ret1 = HAL_I2C_Master_Transmit_DMA(&hi2c1, (0x60<<1), TxD, 3);
// HAL_StatusTypeDef ret1 = HAL_I2C_Master_Transmit(&hi2c1, (0x60<<1), TxD, 3, 10000);
HAL_StatusTypeDef ret1;
ret1 = HAL_I2C_Master_Transmit(&hi2c1, 0x00, TxD, 3, 3000);
ret1 = HAL_I2C_Master_Transmit(&hi2c1, 0x00, TxD, 3, 3000);
ret1 = HAL_I2C_Master_Transmit(&hi2c1, 0x00, TxD, 3, 3000);
ret1 = HAL_I2C_Master_Transmit(&hi2c1, 0x00, TxD, 3, 3000);
sprintf(txt,"TxD sent with %d return \r\n",ret1);
HAL_UART_Transmit(&huart3,(uint8_t*)txt,strlen(txt),1000);
/* USER CODE END 2 */
//H723 slave recive
/* USER CODE BEGIN 2 */
HAL_Delay(1000);
char txt[50];
sprintf(txt,"uart Works for i2c ipc\r\n");
HAL_UART_Transmit(&huart3,(uint8_t*)txt,strlen(txt),1000);
HAL_I2C_Init(&hi2c1);
HAL_Delay(4000);
uint8_t RxD[3] = {0,0,0};
HAL_StatusTypeDef ret1;
ret1 = HAL_I2C_Slave_Receive(&hi2c1, RxD, 3 , 3000);
ret1 = HAL_I2C_Slave_Receive(&hi2c1, RxD, 3 , 3000);
ret1 = HAL_I2C_Slave_Receive(&hi2c1, RxD, 3 , 3000);
ret1 = HAL_I2C_Slave_Receive(&hi2c1, RxD, 3 , 3000);
sprintf(txt,"recived 1= %d , 2= %d , 3= %d ret = %d\r\n",RxD[0],RxD[1],RxD[2],ret1);
HAL_UART_Transmit(&huart3,(uint8_t*)txt,strlen(txt),1000);
/* USER CODE END 2 */
The last 3 lines in both user code 2 parts of the scrit are repeaded in the while loop with no change to the output.
I have been failing to get this to work for a couple of weeks now any advice is massively appreciated.
Solved! Go to Solution.
2024-09-27 02:19 AM
Indeed, addresses 0..7 are specified as Reserved:
2024-09-27 01:54 AM
Change the slave address to something between 0x08 to 0x77. I believe addresses between 0x00 to 0x07 is does not conform to I2C specification
2024-09-27 02:19 AM
Indeed, addresses 0..7 are specified as Reserved:
2024-09-27 06:43 AM
Does HAL_I2C_IsDeviceReady return HAL_OK? If not, don't do anything else until you get that right.
Are external resistors present? If not, you will be reduced to using very slow I2C speeds.
You said you captured the SDA/SCL signals. What do those look like? "Not right" is unfortunately not a helpful description here.
2024-09-28 05:45 AM
Yes, this worked thank you. Initially I had the address set to 0x50 but changed it to 0x00 in case it was causing an issue. I think there was an issue before adding the address issue with the external pullup resistors which was only fixed once i changed the address to 0x00 in the first place. It now works with 0x28 as the address. Thank you again this was a massive help.