Bare metal STM32 programming

Related to the the forum.
alfrond
Posts: 4
Joined: Tue Nov 24, 2020 5:02 pm

Re: Bare metal STM32 programming

Post by alfrond »

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.
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!

User avatar
Bakisha
Posts: 70
Joined: Fri Dec 20, 2019 6:50 pm
Answers: 4
Contact:

Re: Bare metal STM32 programming

Post by Bakisha »

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 me, ST core have very easy register access with CMSIS.
For example, sketch from timer example https://github.com/stm32duino/STM32Exam ... etPWM.ino can be edited by:

Code: Select all

Instance->ARR
or specificly,

Code: Select all

TIM1->ARR
is just changing AutoReloadRegister (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..

alfrond
Posts: 4
Joined: Tue Nov 24, 2020 5:02 pm

Re: Bare metal STM32 programming

Post by alfrond »

What you consider the hard part is all I feel confident about.. :mrgreen:

Thanks ALOT!

ag123
Posts: 517
Joined: Thu Dec 19, 2019 5:30 am
Answers: 1

Re: Bare metal STM32 programming

Post by ag123 »

alfrond wrote:
Thu Nov 26, 2020 4:38 pm
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.
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!
well this thread is about bare metal stm programming isn't it, so besides libmaple there is always RM0008
libmaple is nearly as bare (metal) as it can be, u'd need to code the rest yourself :lol:

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

Post Reply

Return to “Ideas & suggestions”