Skip to main content
BAl K.1
Associate III
July 4, 2023
Solved

PA0_C GPIO PIN

  • July 4, 2023
  • 2 replies
  • 2507 views

I have stm32h745i-disco for my project and use PA0_C and PC_3 for output. and when i use usual HAL_GPIO_WritePin() it is not working. Should i change something to make it work? Please help

 

This topic has been closed for replies.
Best answer by Sarra.S

Hello @BAl K.1, thank you for your post, 

Make sure you configured the GPIO pins, enabled GPIOA, GPIOC

Your code should look something like this : 

/* Enable GPIOA and GPIOC clock */
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();

/* Configure PA0 and PC3 as outputs */
GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

GPIO_InitStruct.Pin = GPIO_PIN_3;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

/* Set the output value of PA0 and PC3 */
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_3, GPIO_PIN_RESET);

Hope that helps!

2 replies

Sarra.SBest answer
ST Employee
July 4, 2023

Hello @BAl K.1, thank you for your post, 

Make sure you configured the GPIO pins, enabled GPIOA, GPIOC

Your code should look something like this : 

/* Enable GPIOA and GPIOC clock */
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();

/* Configure PA0 and PC3 as outputs */
GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

GPIO_InitStruct.Pin = GPIO_PIN_3;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

/* Set the output value of PA0 and PC3 */
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_3, GPIO_PIN_RESET);

Hope that helps!

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
BAl K.1
BAl K.1Author
Associate III
July 5, 2023

Thank you, it works