Skip to main content
Jinyu Z
Associate II
November 17, 2020
Question

Issues on creating a project using STM32CubeMX tool.

  • November 17, 2020
  • 8 replies
  • 1746 views

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?

This topic has been closed for replies.

8 replies

TDK
November 17, 2020

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.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Jinyu Z
Jinyu ZAuthor
Associate II
November 17, 2020

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.

victagayun
Senior III
November 17, 2020

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 */
}

Jinyu Z
Jinyu ZAuthor
Associate II
November 17, 2020

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.

victagayun
Senior III
November 17, 2020

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.