cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L476 IOExpander trouble turning on LEDS

easy
Associate

Hello, I am writing some code to turn on an LED on my board through the IOExpander (STMPE811) but am facing some issues. I am able to read and write to I2C, and have done the following:
written 1 to 0x10 (GPIO_SET_PIN) (Writing 1 to this bit causes the corresponding GPIO to go to 1 state.)

written 1 to 0x13 (GPIO_DIR) (Writing ‘0’ sets the corresponding GPIO to input state, and ‘1’ sets it to output state. All bits are ‘0’ on reset. )

written 1 to 0x10 (GPIO_SET_PIN) (Writing 1 to this bit causes the corresponding GPIO to go to 1 state. Writing 0 has no effect.)

However, I am still unable to turn the LED on. Any advice is appreciated! I have included a portion of my code that is run in the MX_I2C1_Init function when you create a new project on STM32CUBEIDE. 


data[0] = 0x17;
data[1] = 0x1;


HAL_StatusTypeDef status = HAL_I2C_Master_Transmit(&hi2c1, 0x82, &data,2, 0xfff);
if (status != HAL_OK) {
  while(1);
}


status = HAL_I2C_Master_Transmit(&hi2c1, 0x82, &data,1, 0xfff);
if (status != HAL_OK) {
  while(1);
}
status = HAL_I2C_Master_Receive(&hi2c1, 0x82, data,1, 0xfff);
if (status != HAL_OK) {
  while(1);
}


     data[0] = 0x13;
     data[1] = 0x1;

 


     status = HAL_I2C_Master_Transmit(&hi2c1, 0x82, &data,2, 0xfff);
     if (status != HAL_OK) {
      while(1);
     }


     status = HAL_I2C_Master_Transmit(&hi2c1, 0x82, &data,1, 0xfff);
     if (status != HAL_OK) {
          while(1);
         }
     status = HAL_I2C_Master_Receive(&hi2c1, 0x82, data,1, 0xfff);
     if (status != HAL_OK) {
      while(1);
     }

 

 


     data[0] = 0x10;
     data[1] = 0x1;

 


     status = HAL_I2C_Master_Transmit(&hi2c1, 0x82, &data,2, 0xfff);
     if (status != HAL_OK) {
      while(1);
     }


     status = HAL_I2C_Master_Transmit(&hi2c1, 0x82, &data,1, 0xfff);
     if (status != HAL_OK) {
          while(1);
         }
     status = HAL_I2C_Master_Receive(&hi2c1, 0x82, data,1, 0xfff);
     if (status != HAL_OK) {
      while(1);
     }

 



0 REPLIES 0