cancel
Showing results for 
Search instead for 
Did you mean: 

What's the best way to port CMSIS UART from F0 to G0

TDao.19
Associate II

An existing project runs on STM32F091, it use CMSIS USART driver (ARM_DRIVER_USART Driver_USART1). Now I need to migrate this project to run on STM32G070. But in CubeMX for STM32G070, there aren't any USART driver under CMSIS driver, except a header file for customary implementation. So what is the best way to migrate UART functionality? Do I need to implement a similar CMSIS USART driver for G0 series? (CMSIS should be easier for migration, now it seems to cause more trouble.)

17 REPLIES 17
Andrew Neil
Evangelist III

Don't ST provide a suitable driver or HAL or ... ?

Okay so add:

- use a suitable driver or HAL or ... provided by ST

although IMHO it falls under the more general "rewrite the program from scratch".

JW

Piranha
Chief II

The HAL is broken and almost useless because of flawed API design. Sadly CMSIS drivers are also based on HAL. They are kind of more stable, because they are stuffed full with workarounds for the broken HAL, but I doubt the HAL "lock" and other race conditions are fixed. And even if it is, the API is still the dumb receive-stop-receive design. Therefore continuous stream reception is not possible.

Just make your own sane implementation. One can base it on or at least get inspired by this:

https://github.com/MaJerle/stm32-usart-uart-dma-rx-tx

It even has an example for G0.

I try to avoid falling into the rabbit hole of porting UART driver: reliability issue, debugging, and all that.

Thanks for the suggestion. This forum is much better than ARM forum which feels like a ghost town.

Thank you for laying out the options.

Isn't the forum the best chance of getting answers? In my pass experience, contact technical support is often not helpful, they often suggest to ask on the forum and say they have engineers monitor forum and answer tough questions. Anyway I will try my luck with technical support first.

Yeah, but I used CMSIS driver, not HAL driver. And I try to avoid falling into the rabbit hole of porting UART driver: reliability issue, debugging, and all that.

Contacted KEIL/ARM technical support, and their response is:

"We used to implement these drivers on behalf of chip vendors a couple of years back but as mentioned earlier, now days the chip vendors are responsible for these drivers that are part of their DFP."

TDao.19
Associate II

Contacted ST support, here's the response:

We recommend for you to use the HAL APIs included in our STM32Cube libraries to take benefit from the easy migration of firmware from one STM32 family to another. Although CMSIS is part of the STM32Cube library, the APIs used is for Core related operations with some of these functions have HAL macros implemented in STM32Cube library.

STM32Cube libraries have the same architecture and follow the same API naming conventions that use can easily port to other STM32 devices. The library also includes ready to run sample codes for user to use as reference. USART sample codes is of course include as well as preconfigured Keil projects.

We suggest you to start with the available sample codes and build from there.

Please download the related libraries in www.st.com/stm32cube. Look for STM32CubeF0 and STM32CubeG0.

Training and tutorial materials are in www.st.com/stm32education.