Skip to main content
RPatt.11
Associate II
August 5, 2023
Solved

I2C error codes F767ZI

  • August 5, 2023
  • 1 reply
  • 3273 views

I am working to get one F767ZI board (master) to send 1 byte to a second F767ZI (slave).  I'm using 4k external pull-up resistors on SDA and SCL.  I am trapping errors in the master and they are:

After the following code on the master I get "Error 32".

ret = HAL_I2C_IsDeviceReady(&hi2c1, 30,1, 1000);
if ( ret != HAL_OK) {
  uint32_t error_code = HAL_I2C_GetError(&hi2c1); 
  printf("Error %d\r\n", error_code);
  }  

Then, after the following code on the master I get "Error 4".

ret = HAL_I2C_Master_Transmit(&hi2c1, 30, TX_Buffer, 1, 1000); //up to 1 second to try and send
if ( ret != HAL_OK) {
 uint32_t error_code = HAL_I2C_GetError(&hi2c1); 
 printf("Error %d\r\n", error_code);
 }

Since this is my first time ever trying I2C, I'm sure I'm addressing something wrong or some other simple error.

I can't find anything in the HAL/LL reference to tell me what those error codes mean.

thank you, russ

p.s.  My master F767 spits printf statements to UART4 so I can watch it.  My slave F767 spits them to the terminal window in Ozone using SEGGER_RTT.

This topic has been closed for replies.
Best answer by MM..1

Simply your slave dont reply and first error 32 timeout

#define 	HAL_I2C_ERROR_NONE 0x00000000U
#define 	HAL_I2C_ERROR_BERR 0x00000001U
#define 	HAL_I2C_ERROR_ARLO 0x00000002U
#define 	HAL_I2C_ERROR_AF 0x00000004U
#define 	HAL_I2C_ERROR_OVR 0x00000008U
#define 	HAL_I2C_ERROR_DMA 0x00000010U
#define 	HAL_I2C_ERROR_TIMEOUT 0x00000020U

1 reply

RhSilicon
Lead
August 5, 2023

I don't think it's a good idea to try to read an error from the I2C port only when receiving a value other than HAL_OK.

typedef enum
{
    HAL_OK = 0x00U,
    HAL_ERROR = 0x01U,
    HAL_BUSY = 0x02U,
    HAL_TIMEOUT = 0x03U
} HAL_StatusTypeDef;

When I check a device (STM32F4), I have to shift a bit in the address.

For example, the TMP117 address, which is 0x48, after shifting a bit, becomes 0x90; // 0x48 << 1

RPatt.11
RPatt.11Author
Associate II
August 5, 2023

I thought the HAL I2C functions  handle the necessary address adjustments internally, including left-shifting the address by 1 and setting the LSB based on the read/write operation. So, you don't need to left-shift the address manually before passing it to the HAL I2C functions. 

MM..1
MM..1Best answer
Chief III
August 5, 2023

Simply your slave dont reply and first error 32 timeout

#define 	HAL_I2C_ERROR_NONE 0x00000000U
#define 	HAL_I2C_ERROR_BERR 0x00000001U
#define 	HAL_I2C_ERROR_ARLO 0x00000002U
#define 	HAL_I2C_ERROR_AF 0x00000004U
#define 	HAL_I2C_ERROR_OVR 0x00000008U
#define 	HAL_I2C_ERROR_DMA 0x00000010U
#define 	HAL_I2C_ERROR_TIMEOUT 0x00000020U