cancel
Showing results for 
Search instead for 
Did you mean: 

stm32h747i-disco writegpio no funtion

wjian.2
Associate II

i want to add some work on food_recognize.c in fp_AI_VISION ,I want to use CN9 analog to control some leds but it doesn't work in first place. I can't control those pins with writegipo.

so far i only see A0 always on and A1-A5 always off. On the same pin there are two names (from gpio port and mcu pin), for example A2 can be PA0 or PI6, but try both that don't work, I've also tried mcu pin with pinnbr either. A0 always on and the rest always off, no I know which part is wrong (PLL or System Clock Configuration? this part also changes sometimes either) , I have attached the example main.c  if anywhere has a problem.

9 REPLIES 9
TDK
Guru

If you want pins on A0-A3 to be outputs, you need to initialize them as outputs first. You don't do that anywhere in your code. You only initialize PI4 as an output.

Feels like you generated CubeMX code, then modified it. Comments and code are not in alignment. One example of many:

 

  /* Set the output value of PA0 and PC3 */
  HAL_GPIO_WritePin(GPIOI, GPIO_PIN_4, GPIO_PIN_SET);

 

PI4 is connected to memory and doesn't appear in CN9, so why are you changing it?

TDK_0-1690550632321.png

Note that PA0 and PA0_C are different pins. PA0_C can't be an output unless it's tied to PA0 internally.

If you feel a post has answered your question, please click "Accept as Solution".
Piranha
Chief II

Arduino pin numbering has nothing to do with STM32 pin numbers. According to the schematic A0 on CN9 is connected to PA4, but the UM2411 user manual shows PF7. I would guess the user manual is wrong. The author can test it easily...

@KDJEM.1 , this is a documentation error.

i try the command 

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

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

 

/* Set the output value of PA4 */
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET);

and in main

 
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET);
HAL_Delay(1000);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET);
HAL_Delay(1000);

Pin A0 always on

 

 

Because the same pin hay differente name in mcu pin and gpio port,like A2 as PA0_C and PI6 , the problem is those pines A1-A5 in the two name always off(i have try 6 pin ,12 name), A0 always on.

wjian2_0-1690715581520.png

 

"Note that PA0 and PA0_C are different pins. PA0_C can't be an output unless it's tied to PA0 internally." you means a2-a5 could not use as HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET); en mode outputpp?

"A4" and "PA4" mean different things. The latter is a pin on the microcontroller. Pin A4 on the board isn't connected to pin PA4 on the microcontroller, as the table suggests. Read the user manual. Consult the schematic. Note the inconsistency as @Piranha described.

If you feel a post has answered your question, please click "Accept as Solution".

i try A0 as PA4 (HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET) like Piranha say but still no work , not A4.

''Consult the schematic" which page it is in user manual?

Hello @Piranha ,

Thank you for bringing this issue to our attention.

I will check internally.

Internal ticket number: 158369 (This is an internal tracking number and is not accessible or usable by customers).

Thank you.

Kaouthar

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.

KDJEM.1
ST Employee

Hello,

The issue is solved in UM2411 Rev 6.

Thank you.

Kaouthar

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.