‎2020-11-16 06:43 PM
Following the instructions below, I create a new project.
https://wiki.st.com/stm32mcu/wiki/STM32StepByStep:Step2_Blink_LED
But it seems that the led blinking thread fails to get started.
I must comment some system initialization to get the default thread ran.
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_ADC1_Init();
MX_ADC3_Init();
MX_CRC_Init();
MX_DMA2D_Init();
MX_ETH_Init();
MX_FMC_Init();
MX_HDMI_CEC_Init();
MX_I2C1_Init();
MX_I2C4_Init();
//MX_IWDG_Init();
MX_LTDC_Init();
MX_QUADSPI_Init();
MX_RTC_Init();
MX_SAI1_Init();
MX_SAI2_Init();
//MX_SDMMC2_MMC_Init();
MX_SPDIFRX_Init();
MX_SPI2_Init();
MX_TIM1_Init();
MX_TIM3_Init();
MX_TIM10_Init();
MX_TIM11_Init();
MX_TIM12_Init();
MX_UART5_Init();
MX_USART1_UART_Init();
MX_USART6_UART_Init();
MX_USB_OTG_HS_PCD_Init();
//MX_WWDG_Init();
What's the problem?
‎2020-11-16 07:18 PM
It looks like you have *way* more things going on in your project than in the blink LED example. Maybe strip it down to the bare blink LED code and go from there.
‎2020-11-16 09:52 PM
Yes, you're right. But this is not the issue. I created the project using the STM32CubeMX tool and all the things were selected by default, I didn't change anything.
Thus, the issue came.
I want to know why. Is it about the source code generated by STM32CubeMX or configuration errors?
The next step, I will figure out how to strip them down.
‎2020-11-16 10:54 PM
Can you check the interrupt file if it has these codes?
The IncTick needs to be incremented so the Hal Delay will function.
void SysTick_Handler(void)
{
/* USER CODE BEGIN SysTick_IRQn 0 */
/* USER CODE END SysTick_IRQn 0 */
HAL_IncTick();
/* USER CODE BEGIN SysTick_IRQn 1 */
//HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET);
/* USER CODE END SysTick_IRQn 1 */
}
‎2020-11-16 11:13 PM
the STM32F769I-DISCO board use TIM6 as SysTick, in interrupt file:
void TIM6_DAC_IRQHandler(void)
{
/* USER CODE BEGIN TIM6_DAC_IRQn 0 */
/* USER CODE END TIM6_DAC_IRQn 0 */
HAL_TIM_IRQHandler(&htim6);
/* USER CODE BEGIN TIM6_DAC_IRQn 1 */
/* USER CODE END TIM6_DAC_IRQn 1 */
}
// the final callback in main.c file
/**
* @brief Period elapsed callback in non blocking mode
* @note This function is called when TIM6 interrupt took place, inside
* HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
* a global variable "uwTick" used as application time base.
* @param htim : TIM handle
* @retval None
*/
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
/* USER CODE BEGIN Callback 0 */
/* USER CODE END Callback 0 */
if (htim->Instance == TIM6) {
HAL_IncTick();
}
/* USER CODE BEGIN Callback 1 */
/* USER CODE END Callback 1 */
}
when debugging the MX_SDMMC2_MMC_Init() function, it is blocked at the below lines:
/* While card is not ready for data and trial number for sending CMD13 is not exceeded */
count = SDMMC_DATATIMEOUT;
while((response & 0x00000100U) == 0U)
{
if(count == 0U)
{
hmmc->State = HAL_MMC_STATE_READY;
hmmc->ErrorCode |= HAL_MMC_ERROR_REQUEST_NOT_APPLICABLE;
return HAL_ERROR;
}
count--;
......
}
the count variable is equal to 0xFFFFFFFFU.
‎2020-11-16 11:30 PM
so you set all pins as default?
Maybe try to reset all pins first then use Timebase Source as Systic not TIM6.
Set your GPIO output (with LED).
Then in NVIC make sure "Timebase : Systic time" and "IRQ and Call handler" are both checked then run.
‎2020-11-16 11:46 PM
Year, I understand your concern.
I create a new project with STM32CubeMX, all the pins and peripherals are configured by default(I select the STM32F769I-DISCO board in Board Selector section).
The modification I only do is setting LD_USER2(Green led) to GPIO_MODE_OUTPUT_PP mode. The source code generated by the tool:
/*Configure GPIO pin : LD_USER2_Pin */
GPIO_InitStruct.Pin = LD_USER2_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(LD_USER2_GPIO_Port, &GPIO_InitStruct);
Also, after I comment the Initialization to SDMMC and watchdogs, the led blinking at a frequency of 1Hz(the default thread get ran successfully, check below code).
/* USER CODE BEGIN Header_StartDefaultTask */
/**
* @brief Function implementing the defaultTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartDefaultTask */
void StartDefaultTask(void const * argument)
{
/* USER CODE BEGIN 5 */
/* Infinite loop */
for(;;)
{
HAL_GPIO_TogglePin(GPIOJ, GPIO_PIN_5);
osDelay(500);
}
/* USER CODE END 5 */
}
‎2020-11-17 12:15 AM
Sorry I misread your problem.
So you need to disable some peripheral init to make it run.
Maybe try to examine the example of the ff in the fw package if it were set correctly.
//MX_IWDG_Init();
//MX_SDMMC2_MMC_Init();
//MX_WWDG_Init();
OR did you insert any SDcard in there too?
Anyway, I will get this board this week and be able to try it too...
‎2020-11-17 12:24 AM
I didn't insert a SD card into the slot as no one had asked me to do so.:face_savoring_food: Maybe this is the cause.
Do you think the watchdogs should be disabled when debugging?