Skip to main content
Visitor II
March 2, 2021
Question

STM32F767ZI Nucleo LED Blink Not working

  • March 2, 2021
  • 1 reply
  • 2704 views

Hello, I am getting started with the STM32F767ZI Nucleo board, and I am trying to do something pretty basic -- blinking some of the LEDs. I have the F7 ioc setup as default, and I am trying to run the HAL_GPIO_TogglePin in the main while loop. When I run the debugger, nothing happens on the board. If I set the default state in the IOC file to High, the LED turns on, no problem. So I know the LED is connected and everything should be configured as normal, but nothing works.

Other than the toggle code, everything is default and compiles and runs with no errors or warnings.

 while (1)
 {
	 HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0);
	 /* Insert delay 100 ms */
	 HAL_Delay(100);
 /* USER CODE END WHILE */
 
 /* USER CODE BEGIN 3 */
 }
 /* USER CODE END 3 */
}
 
 
 
 HAL_GPIO_WritePin(GPIOB, LD1_Pin|LD3_Pin|LD2_Pin, GPIO_PIN_RESET);
 
 /*Configure GPIO pin Output Level */
 HAL_GPIO_WritePin(USB_PowerSwitchOn_GPIO_Port, USB_PowerSwitchOn_Pin, GPIO_PIN_RESET);
 
 /*Configure GPIO pin : USER_Btn_Pin */
 GPIO_InitStruct.Pin = USER_Btn_Pin;
 GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 HAL_GPIO_Init(USER_Btn_GPIO_Port, &GPIO_InitStruct);
 
 /*Configure GPIO pins : LD1_Pin LD3_Pin LD2_Pin */
 GPIO_InitStruct.Pin = LD1_Pin|LD3_Pin|LD2_Pin;
 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 //HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 
 /*Configure GPIO pin : USB_PowerSwitchOn_Pin */
 GPIO_InitStruct.Pin = USB_PowerSwitchOn_Pin;
 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 HAL_GPIO_Init(USB_PowerSwitchOn_GPIO_Port, &GPIO_InitStruct);
 
 /*Configure GPIO pin : USB_OverCurrent_Pin */
 GPIO_InitStruct.Pin = USB_OverCurrent_Pin;
 GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 HAL_GPIO_Init(USB_OverCurrent_GPIO_Port, &GPIO_InitStruct);

Please help! I don't know why I can't get something so simple to work.

    This topic has been closed for replies.

    1 reply

    Super User
    March 3, 2021

    If the code is generated, it should work. Try using the generated macros for the LED like LD1_GPIO_Port and LD1_Pin and: try another LED. If I look at the board schematics there is some remark "8. LD1 can be controlled by PB0 from A-01 to B-01" implying that LD1 might not work if your board revision is A.

    hth

    KnarfB

    CChan.9Author
    Visitor II
    March 3, 2021

    I tried almost the same code on a different Nucleo board (the H753ZI), and it worked very easily. When I go through the debugger on the the F7 code, I noticed that it never reaches the break points in the main while(1) loop. It goes straight to the void Error_Handler(void) { while(1){}} loop.

    Super User
    March 3, 2021

    Then, find out what caused that early error by steppting though the code and wathing the call stack. Could be RCC clock setup or such.

    hth

    KnarfB