I am developing an application for a University project on my STM32L1DISCO board with the STM32L152RC MCU.
I have configured the pins and generated the init code via STM32CubeMX. I am using Atollic TrueSTUDIO as the IDE.
The problem is that the generated init code cannot run on my MCU. After spending a lot of time on debugging I found that the problem in the code is this one line using the HAL gpio library:
Even though the preceding code is correct,
GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(IDD_CNT_EN_GPIO_Port, IDD_CNT_EN_Pin, GPIO_PIN_RESET); /*Configure GPIO pin : IDD_CNT_EN_Pin */ GPIO_InitStruct.Pin = IDD_CNT_EN_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
After stepping through the code line-by-line during debugging, I found that the HAL GPIO Init function does not execute and instead gives the runtime error: "Target not Responding, retrying...".
When I comment the HAL GPIO Init line, the program runs through with no issues.
STM32CubeMX includes the HAL library in the code. On top there is,
So, I'm not sure what's causing the issue I'm seeing. I would really appreciate your help on this as I don't know what to try next.