How to program new STM32s with no Standard Peripheral Library? - Page 1
Forum section: electronics / general

author: Red_Micro
author_rank: Regular Contributor
timestamp: May 01, 2020, 07:56:29 pm
content: I want to learn programming at register level using a STM32G030 microcontroller. I only see the HAL library available, but not the SPL. Would I need to create my own header file for this micro to program it using registers?

author: bingo600
author_rank: Super Contributor
timestamp: May 01, 2020, 08:51:34 pm
content: Quote from: Red_Micro on May 01, 2020, 07:56:29 pmFor .h filesLook at the CMSIS package for the MCU , they usually defines redisters , bits etc/Bingo

author: thm_w
author_rank: Super Contributor
timestamp: May 01, 2020, 08:52:22 pm
content: Page 168:https://www.st.com/content/dam/AME/2019/STM32G0-q1-webinar-workshops/STM32G0_Workshop_Presentation.pdfUse LL drivers with cubemx, or directly use the CMSIS header fileshttps://github.com/STMicroelectronics/STM32CubeG0/blob/master/Drivers/CMSIS/Device/ST/STM32G0xx/Include/stm32g030xx.h

author: ataradov
author_rank: Super Contributor
timestamp: May 01, 2020, 11:23:55 pm
content: I have a simple bare-metal starter project for STM32G0 herehttps://github.com/ataradov/mcu-starter-projects/tree/master/stm32g0Do not createte your own hearer files. Just download a CMSIS pack file and you will get everything you need.

author: pablintino
author_rank: Contributor
timestamp: May 02, 2020, 12:11:50 am
content: As others have said simply use the headers from the CMSIS folder. Those headers contains all the definitions you need to configure the device at register level.

author: jackthomson43
author_rank: Contributor
timestamp: May 02, 2020, 06:46:26 am
content: If you want to do everything by yourself then try assembly language, too lengthy but too flexible. You can do anything in it. But not forSTM32.

author: westfw
author_rank: Super Contributor
timestamp: May 02, 2020, 09:20:49 am
content: Are the CMSIS files downloadable separately these days?I think the last time I looked, you had to download the whole CUBE system, install it, and then extract the relevant .h files...(Hmm. Looks like you could get a fair number of the CMSIS files from the STM32Duino project github site:https://github.com/stm32duino/Arduino_Core_STM32/tree/master/system/Drivers/CMSIS/Device/ST)

author: techman-001
author_rank: Frequent Contributor
timestamp: May 02, 2020, 10:09:05 am
content: Quote from: westfw on May 02, 2020, 09:20:49 amThe Keil site has them all, here is one for the STM32F0xx: Keil.STM32F0xx_DFP.2.0.0.pack 65147KJust Google the chip, keil and cmsis.

author: pablintino
author_rank: Contributor
timestamp: May 02, 2020, 10:50:50 am
content: ST has being pushing all the Cube libs to Github since past year. This, for example, is the repo for the F3 family:https://github.com/STMicroelectronics/STM32CubeF3. There is a repository for each family in the STMicroelectronics account at Github. No need to install the CubeIDE, CubeMX or anyother software to get a simple header file.

author: dgtl
author_rank: Regular Contributor
timestamp: May 02, 2020, 12:29:06 pm
content: Things you'll need:* uc register header file (what register is at which address, register bit defines),* cmsis header files (usually included from uc header, add some ARM generic registers and cpu-related stuff)* interrupt vector table,* reset vector/c runtime initialization code (typically ASM, handles zeroing bss memory, copies initial values from flash to ram, call main()),* linker script* makefileAll of these can be extracted from cubemx pack or existing projects. The only part of code in the list above is the reset vector code. The rest is up to you, you'll need to set up the clocking and configure everything yourself.

author: ataradov
author_rank: Super Contributor
timestamp: May 02, 2020, 05:06:37 pm
content: Quote from: techman-001 on May 02, 2020, 10:09:05 amYep. Keil site is my primary source for packs.

author: rhodges
author_rank: Frequent Contributor
timestamp: May 02, 2020, 11:58:20 pm
content: Read the datasheet. Read it again. Write your code. Read the datasheet again.

author: westfw
author_rank: Super Contributor
timestamp: May 03, 2020, 12:55:10 am
content: QuoteThanks.vendor files on github is a fine idea!It's also nice that they've switched from a proprietary license the BSD 3-clause...