2021-03-02 03:42 PM
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.
2021-03-03 12:34 AM
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
2021-03-03 09:11 AM
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.
2021-03-03 11:39 AM
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
2024-10-06 07:01 PM
Thanks.
I'm using the Nucleo-F103RB board and generating code with CubeMX. I noticed something odd when trying to toggle the on-board LED (LD2).
The following works perfectly to toggle LD2:
HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);
However, this doesn't toggle the LED:
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
From what I understand, LD2 is connected to GPIOA_PIN_5 on the Nucleo board, so I'm unsure why the second approach doesn't work. Could you explain why this happens?