cancel
Showing results for 
Search instead for 
Did you mean: 

can't make interrup callback work

Chao
Senior

Hi,

I am a newbie to CubeIDE and STM32 Mcus, and have spent hours trying to make interrupt callback work on a Nucleo-STM32G070 board.

First, I tried HAL_UART_TxCpltCallback for USART2, this function is not called, then I downloaded an example project TIM_TimeBase which works, but when I added the timer 3 into my test project with the same configuration as in the example project, it does not work.

I must have missed something in configuration in my project. 

Chao_0-1707314144251.png

Chao_1-1707314190727.png

the Priority is not configurable

 

Chao_2-1707314294871.png

Chao_3-1707314348468.png

again, the Priority is not configurable

 

Chao_4-1707314435175.png

As for the Timer 3, I am a bit confused by the calculation of the prescaler in the example project, could someone clarify it to me:

Chao_5-1707314857870.png

Actually, in system_stm32g0xx.c, it is defined as follow:

uint32_t SystemCoreClock = 16000000U;

 

Regards

Chao

12 REPLIES 12

>Do you write your code "from scratch" or based on some examples

Yes, I do write my test code "from scratch" AND based on some examples,  trying to understand the "HAL" library functions and available example projects by reading the sources.

I have plenty of C++ code with hardware configuration to be ported from NXP platform to STM32CubeIDE, but CubeIDE and the sources in "HAL" library are less intuitive than NXP platform, I am basically a C++/Java programmer with basic understanding of C and hardware, but I managed to use the NXP drivers for UART within a couple of minutes without reading any sources or documentations. 

Are there any documentation on explaining the functionality of the HAL drivers, and the conditions of using them, and what I need to do in user codes when use them?

>Why are you printing one character at a time?

This is a long story on having printf work and I can't see the implementation of printf. What I want to do is exactly what you suggested except for using interrupt rather than using polling mode:

I have a message queue buffer with multiple messages in it, the messages will be sent piece by piece to PC through ST-Link Virtual Com Port, and the data transimission is controlled by Tx-Completed interrupt, this is the mechanism of the code to be ported.

Thank you for your help.

Pavel A.
Evangelist III

Yes there's some documentation, but it er, leaves room for improvement. Help files in windows format (chm) are installed with the HAL library packages. These help files are mostly doxygen generated. For some MCUs they also converted it to PDF [example stm32f4]

There are also "getting started" PDFs . A good collection of documents for specific STM32 family is presented by CubeIDE on the start page or in CubeMX documentation  section. Many aspects are similar across all STM32 families, so information for other  STM32s can be useful too. But mainly, use your time, read the library sources.