STMicroelectronics / STM32CubeG0

STM32Cube MCU Full Package for the STM32G0 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))
Other
165 stars 75 forks source link

HAL_Delay() hangs on code generated from STM32CubeMX #39

Closed Jason-Duffy closed 2 years ago

Jason-Duffy commented 2 years ago

Setup/Environment

I'm bringing up a board featuring an STM32G030C8T6, the board features external crystal but for now I'm just using the internal one. I generated the code using CubeMX, upto date with Firmware version 1.6.1 for STM32G0 series. I'm compiling and flashing using STM32CubeIDE (V1.10.1), with an STLINK V3SET. I have been able to reproduce the same issue with GCC-ARM-11.2 compiler, built and flashed with ST-Link CLI.

Bug

My code hangs on HAL_Delay(), stepping through with the debugger reveals that SysTick isn't incrementing.

Temporary Solution

I managed to fix the issue by uncommenting line 117 in system_stm32g0xx.c, as per the fix in this issue:

https://github.com/STMicroelectronics/STM32CubeF4/issues/113

This leads me to believe that the root cause of the bug could be very similar in nature. HOWEVER. When I hit the reset button, the code hangs instantly. This leads me to believe there is possibly a bootloader issue. Re-flashing the device resumes normal function.

/************************* Miscellaneous Configuration ************************/
/* Note: Following vector table addresses must be defined in line with linker
         configuration. */
/*!< Uncomment the following line if you need to relocate the vector table
     anywhere in Flash or Sram, else the vector table is kept at the automatic
     remap of boot address selected */
#define USER_VECT_TAB_ADDRESS               // JASON uncommented this line. 

#if defined(USER_VECT_TAB_ADDRESS)

Steps to reproduce (From CubeMX):

Clock_Config NVIC_Settings Pinout Schem

Jason-Duffy commented 2 years ago

Ah... OK sorry, the actual reason for this bug was far more embarrassing. I had my RX and TX crossed on a USART adapter port! Closing the issue now.