cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U5 AzureRTOS GPIO some inputs do not work

IgorBecker
Visitor

Hello everyone, thanks for your help.

I have a problem regarding the states of inputs that were set exactly the same way.

After powering all 10 inputs simultaneously, inputs IN4, IN5, IN6 and IN7 are not in SET, the others are in SET.

 

Relevant data:
Using STM32U535RCT6Q, Azure RTOS, IAR

/* Private defines -----------------------------------------------------------*/
#define IN1_Pin GPIO_PIN_0
#define IN1_GPIO_Port GPIOB
#define IN2_Pin GPIO_PIN_1
#define IN2_GPIO_Port GPIOB
#define IN3_Pin GPIO_PIN_2
#define IN3_GPIO_Port GPIOB
#define IN4_Pin GPIO_PIN_10
#define IN4_GPIO_Port GPIOB
#define IN5_Pin GPIO_PIN_13
#define IN5_GPIO_Port GPIOB
#define IN6_Pin GPIO_PIN_14
#define IN6_GPIO_Port GPIOB
#define IN7_Pin GPIO_PIN_15
#define IN7_GPIO_Port GPIOB
#define IN8_Pin GPIO_PIN_6
#define IN8_GPIO_Port GPIOC
#define IN9_Pin GPIO_PIN_7
#define IN9_GPIO_Port GPIOC
#define IN10_Pin GPIO_PIN_8
#define IN10_GPIO_Port GPIOC

Summary code for reading the pins used:

 

typedef struct
{
   GPIO_TypeDef* Port;
   uint16_t Pin;
}GPIO_Input;

#define NUM_INPUTS 10

GPIO_Input inputs[NUM_INPUTS] =
{
{IN1_GPIO_Port, IN1_Pin},
{IN2_GPIO_Port, IN2_Pin},
{IN3_GPIO_Port, IN3_Pin},
{IN4_GPIO_Port, IN4_Pin},
{IN5_GPIO_Port, IN5_Pin},
{IN6_GPIO_Port, IN6_Pin},
{IN7_GPIO_Port, IN7_Pin},
{IN8_GPIO_Port, IN8_Pin},
{IN9_GPIO_Port, IN9_Pin},
{IN10_GPIO_Port, IN10_Pin}
};

void inputsThread(ULONG initial_input)
{
GPIO_PinState dataInputs[NUM_INPUTS];
while (1)
{
for (uint8_t i = 0; i < sizeof(dataInputs); i++)
{
dataInputs[i] = HAL_GPIO_ReadPin(inputs[i].Port, inputs[i].Pin);
}
tx_thread_sleep(1);
}
}

It was verified that the problem pins have values ​​in the most significant byte in the stm32u5xx_hal_gpio.h file:

#define GPIO_PIN_0 ((uint16_t)0x0001)
#define GPIO_PIN_1 ((uint16_t)0x0002)
#define GPIO_PIN_2 ((uint16_t)0x0004)
#define GPIO_PIN_3 ((uint16_t)0x0008)
#define GPIO_PIN_4 ((uint16_t)0x0010)
#define GPIO_PIN_5 ((uint16_t)0x0020)
#define GPIO_PIN_6 ((uint16_t)0x0040)
#define GPIO_PIN_7 ((uint16_t)0x0080)
#define GPIO_PIN_8 ((uint16_t)0x0100)
#define GPIO_PIN_9 ((uint16_t)0x0200)
#define GPIO_PIN_10 ((uint16_t)0x0400)
#define GPIO_PIN_11 ((uint16_t)0x0800)
#define GPIO_PIN_12 ((uint16_t)0x1000)
#define GPIO_PIN_13 ((uint16_t)0x2000)
#define GPIO_PIN_14 ((uint16_t)0x4000)
#define GPIO_PIN_15 ((uint16_t)0x8000)
#define GPIO_PIN_ALL ((uint16_t)0xFFFF)

 

 

 

 

 

1 REPLY 1
Andrew Neil
Evangelist III

Please see the tips for posting:

https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/ta-p/575228

In particular, how to properly post source code.

Also, please provide full details of the board you are using