cancel
Showing results for 
Search instead for 
Did you mean: 

STM32(F4) register programming

uli stone
Associate II
Posted on August 08, 2017 at 18:56

Hi,

I would like to programm my mcu (stm32f4) directly with the reference manual. Are there some examples from ST to see how it is done? I would need for the start examples of: I'C and GPIO.

Hope you could help me,

thank you

#stm32f4 #stm32 #reference-manual #register-level-stm32
6 REPLIES 6
Posted on August 08, 2017 at 19:18

Hello !

You mean to write directly to registers. with no any kind of higher level structure?

If yes, there is no such code published.

But for your need,  to help you learn or understand better register level programming , exists the LL recenly released firmware from ST. (LOW LEVEL)

You can find 

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-embedded-software/stm32cubef4.html

a lot of examples , I2c, GPIOs etc

You can also use

http://www.st.com/content/st_com/en/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-configurators-and-code-generators/stm32cubemx.html

to produce initialization code for your project at LowLevel code .
matic
Associate III
Posted on August 08, 2017 at 19:54

Hi,

For that kind of programming, Reference Manual is your best companion. You should read the section you are interested in for a few times (let say GPIO) and then you will start to understand it. At the beginning it takes some time, but for each further use, you will be much more familiar. I started like this and I don't even look to the HAL/LL confusion any more. Code is much more cleaner, smaller, faster and when you are familiar with those registers, it becomes more readable too. At least for me. In RM you have very precise description how to do things and detailed description of each bit in each register. It could not be more straight forward than that.

Best regards.

Posted on August 08, 2017 at 19:59

There are such examples at the end of the 'F0/L0 RMs, eg. RM0091. The same is in the Snippets library for F0 and L0.

I have some barebones examples (although not specifically for 'F4) on efton.sk/STM32 .

JW

PS. Do you have a debugger? There's lots of fun doing this kind of things directly in the debugger, blink LEDs, set up timers etc.

uli stone
Associate II
Posted on August 08, 2017 at 23:21

Hi,

thank you for all your hints, very good!

One question, I only can produce HAL Code with CubeMX. How can I get LL working? In settings, I can only choose HAL. How to add LL?

Thank you

Posted on August 09, 2017 at 00:26

Hi again!.

You have right. LL produced by cube is not available.

take a look at

https://community.st.com/0D50X00009XkeaBSAR

from community
Posted on August 09, 2017 at 03:41

Review the source code for the SPL to understand register level interactions. You can look at the HAL also, but it is macro heavy.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..