Unable to get LED to toggle with STM32Cube
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-03-27 4:34 PM
Hello,
I'm evaluating STM32cube, to see how it performs. I have a simple project in IAR which I created in STM32Cube for the F407 discovery kit. Enable PortD.12 and D/13 as outputs. However when I insert the toggle code in main(), I'm unable to see the LED toggle on D.13 Any help is appreciated. Thanks!int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_13 );
HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_13 );
/* Code generated for FreeRTOS */
/* Create Start thread */
osThreadDef(USER_Thread, StartThread, osPriorityNormal, 0, 2 * configMINIMAL_STACK_SIZE);
osThreadCreate (osThread(USER_Thread), NULL);
/* Start scheduler */
osKernelStart(NULL, NULL);
/* We should never get here as control is now taken by the scheduler */
/* USER CODE BEGIN 3 */
/* Infinite loop */
while (1)
{
}
/* USER CODE END 3 */
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-03-28 1:30 AM
Check the tutorial in STM32CubeMX User Manual. It shows the configuration in MX UI and the code to add in the main function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-03-28 3:11 AM
If you toggle a pin two times without delay you won't be able to see the LED toggling with the eye. You might be able to see them with an oscilloscope, depending on the processor's speed.
A HAL_Delay(500) between the toggle commands should suffice to see the LED toggling if the pins are configured correctly. Hope that helps you, BS- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-03-28 5:01 AM
Thanks... I'm using break points though and stepping through the code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-03-28 5:09 AM
I've the same situation here, with all 4 LED's (PD12-15) configured on Port D and they are toggling just fine. Maybe the port configuration (MX_GPIO_Init) is wrong? Here's the configuration of the Port D on my uC:
GPIO_InitTypeDef GPIO_InitStruct;
__GPIOD_CLK_ENABLE();
/*Configure GPIO pins : PD12 PD13 PD14 PD15 */
GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-03-28 5:12 AM
Update: They were not configured as outputs.
Works now. Thanks!