thanks alot, but libmaple seems obsolete (according even to their own github readme..). has anyone another clear example of mixed low and higher level timer register settings? It would be much appreciated!stevestrong wrote: Tue Nov 24, 2020 7:03 pm Here you can find an example how to mix timer register settings on low and higher level using Libmaple core.
Bare metal STM32 programming
Re: Bare metal STM32 programming
Re: Bare metal STM32 programming
For me, ST core have very easy register access with CMSIS.alfrond wrote: Thu Nov 26, 2020 4:38 pm
thanks alot, but libmaple seems obsolete (according even to their own github readme..). has anyone another clear example of mixed low and higher level timer register settings? It would be much appreciated!
For example, sketch from timer example https://github.com/stm32duino/STM32Exam ... etPWM.ino can be edited by:
Code: Select all
Instance->ARR
Code: Select all
TIM1->ARR
You can find what registers there are (for example stm32f10xb) at https://github.com/stm32duino/Arduino_C ... #L474-L500
Bit positions in register is in same file, https://github.com/stm32duino/Arduino_C ... xb.h#L3799
All devices have their unique names, https://github.com/stm32duino/Arduino_C ... #L648-L688
Hard part is knowing what registers/bits need to be set to do what you want to do, but that's bare metal way..
Re: Bare metal STM32 programming
What you consider the hard part is all I feel confident about.. 
Thanks ALOT!

Thanks ALOT!
Re: Bare metal STM32 programming
well this thread is about bare metal stm programming isn't it, so besides libmaple there is always RM0008alfrond wrote: Thu Nov 26, 2020 4:38 pmthanks alot, but libmaple seems obsolete (according even to their own github readme..). has anyone another clear example of mixed low and higher level timer register settings? It would be much appreciated!stevestrong wrote: Tue Nov 24, 2020 7:03 pm Here you can find an example how to mix timer register settings on low and higher level using Libmaple core.
libmaple is nearly as bare (metal) as it can be, u'd need to code the rest yourself

the syntax in libmaple code and official core codes (in particular within HAL) are the examples of how to access registers.
they aren't simply examples, they actually work, the rest takes trial & error to learn them, e.g. try to blink the led from registers, not too difficult an example would be to do a code review of digitalWrite() dig down into the function calls till you see how the registers are accessed,
an IDE helps with this, e.g. doing reference jumps from function to function, eclipse, vscode etc has that

the other thing to get into 'bare metal' programming is get an st-link v2
https://www.st.com/en/development-tools/st-link-v2.html
https://www.adafruit.com/product/2548
https://octopart.com/search?q=st-link+v2&specs=0
learn to debug on a live processor
there are lots of blogs and webs about mcu programming e.g.
https://mcuoneclipse.com/
there is this eclipse plugin i tried
https://mcuoneclipse.com/2017/07/26/emb ... nd-oxygen/
https://sourceforge.net/projects/embsys ... iew/0.2.6/
debugging in eclipse with the plugin added gives a 'pro' view of what happens every instruction, you can step every line of C/C++ code and even the assembly instructions, and embsysregview literally lays out the whole suite of nicely labelled peripheral registers and their realtime values
it is invaluable for troubleshooting and learning stm32
it is possible to do the same with command line gdb and openocd, just more tedious and you won't get that everything on the panel look & feel
Re: Bare metal STM32 programming
CMSIS is the past, present and future. Any (software) platform not built on it is in my view doomed - aka on borrowed time.has anyone another clear example of mixed low and higher level timer register settings?
It is much better, if one wants to stay with the current stm32duino source code, to port it over to CMSIS.
-
- Posts: 633
- Joined: Thu Dec 19, 2019 1:23 am
Re: Bare metal STM32 programming
Hackaday STM32 article:
https://hackaday.com/2020/11/17/bare-me ... llo-world/
Also, free:
https://hackaday.com/2020/11/17/bare-me ... llo-world/
Also, free:
Discovering the STM32 Microcontroller
Geoffrey Brown
©2012
January 1, 2016
Re: Bare metal STM32 programming
strictly speaking both libmaple & official core is pretty much 'bare metal', pretty close.
when one makes a sketch, it bundles the core, the core is bare metal, and there is nothing preventing anyone from improving the core to run better.
if one wants to do it 'from scratch' one could always do so, but that being 'from scratch' is different from 'bare metal', the core interfaces directly with the registers, it isn't literally 'separate' from your sketch.
when one makes a sketch, it bundles the core, the core is bare metal, and there is nothing preventing anyone from improving the core to run better.
if one wants to do it 'from scratch' one could always do so, but that being 'from scratch' is different from 'bare metal', the core interfaces directly with the registers, it isn't literally 'separate' from your sketch.