Skip to main content
Visitor II
July 28, 2023
Question

stm32h747i-disco writegpio no funtion

  • July 28, 2023
  • 3 replies
  • 2383 views

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.

    This topic has been closed for replies.

    3 replies

    Super User
    July 28, 2023

    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.

    wjian.2Author
    Visitor II
    July 30, 2023

    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

     

    Graduate II
    July 28, 2023

    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.

    wjian.2Author
    Visitor II
    July 30, 2023

    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

     

     

    Technical Moderator
    March 27, 2024

    Hello,

    The issue is solved in UM2411 Rev 6.

    Thank you.

    Kaouthar