2018-10-17 08:19 AM
Hi, I have a problem with a minimal project using STM32CubeMX (version 4.27), an STM32F407VG and generating code for MDK-ARM5 (Keil). I create a new project, configure UART3 on pins PD8 and PD9. I add a simple printout on the UART in the main loop (not in an interrupt) giving the HAL_GetTick() as an ascii string and the value stays at zero continously. Similarly, any calls to HAL_Delay etc. hangs the processor.
I've also tested to configure the RCC (HSE crystal) and clock settings (HSE 8mhz, using "resolve clock issues") in addition to the UART, but with the same results. Am I missing some other important configuration to be done in the CubeMX gui or should I add any user code to ensure that SysTick_Handler is called?
The only added code are as below, in the sections indicated by the USER CODE comments in Src/main.c.
/* USER CODE BEGIN 0 */
void uart_send (const char *str) {
uint16_t size;
for (size=0; str[size] != 0; size++);
HAL_UART_Transmit(&huart3, (uint8_t *) str, size, HAL_MAX_DELAY);
}
void format_digit(char *str, uint8_t digits, uint32_t value){
str[digits] = 0;
for (; digits > 0; digits--) {
str[digits - 1] = '0' + (value % 10);
value = value / 10;
}
}
/* USER CODE END 0 */
/* USER CODE BEGIN 1 */
char str[256];
/* USER CODE END 1 */
/* USER CODE BEGIN WHILE */
while (1)
{
format_digit(str, 6, HAL_GetTick());
uart_send(str);
uart_send("\n\r");
/* USER CODE END WHILE */
Solved! Go to Solution.
2018-10-22 12:38 AM
Thank you, I figured out that the problem was that I had re-located the code with an offset in the linker script due to a bootloader -- this shifted the placement of the IRQ table and I had to manually override the value of SCB->VTOR in the generated Src/system_stm32f4xx.c file.
2018-10-17 08:38 AM
Review working code examples in the CubeF4 code trees.
The SysTick is usually configured in code within, or called by, HAL_Init()
2018-10-22 12:38 AM
Thank you, I figured out that the problem was that I had re-located the code with an offset in the linker script due to a bootloader -- this shifted the placement of the IRQ table and I had to manually override the value of SCB->VTOR in the generated Src/system_stm32f4xx.c file.