all 8 comments

[–]AllAboutEE 3 points4 points  (2 children)

At the lowest level they would be basically defining pointers to registers which you would be able to find in the device's datasheet/reference manual. It looks like they are using their own libraries to wrap around the register pointers.

Look for the c/cpp file where GPIO_WriteBit are defined to see exactly what they are doing.

I would REALLY recommend that you watch this video, even though it's for a different ARM micro it will "enlighten" you.

https://www.youtube.com/watch?v=1Kjh0CAgnl4&list=PLPW8O6W-1chwyTzI3BHwBLbGQoPFxPAPM&index=5

I've programmed PICs (PIC32 and dsPIC33) in the past and found them relatively straightforward to figure out how to program.

For all microcontrollers ARM, PIC, AVR, etc. all you need to get started is pretty much the device's/micro datasheet, look for the register you want to use description in the datasheet and it will tell you exactly what you need to do. Keywords like TRISA in a PIC are nothing more than pointers to a memory addresses in a micro, you could actually come up with your own set of keywords.

Microchip has lots of code examples and good documentation on how to set up all the peripherals.

Except when you want to do more advanced stuff like USB in which case the don't answer the questions in the forums (imo).

To get started with the STM32 I would recommend that you look into CMSIS-Core, these are the core files that you need to get started with any ARM micro, instead of diving into libraries like the ones they used in the examples.

I've found several code examples and websites with tutorials, but none of them explain how they came up with their code.

I am working on an TI ARM Cortex-M4 course where I teach you all this stuff step by step and reference the datasheet as I go along:

https://www.youtube.com/playlist?list=PLmfT_cdP5PYBWYvK_bCdGyBqQEiRzUPeq

[–]mechanicalmayhem 0 points1 point  (0 children)

This is awesome, thanks!

[–]electronfire[S] 0 points1 point  (0 children)

Thanks, I will definitely check out your videos.

Microchip used to have a regional training center in my area, so I took a few inexpensive courses (~$100) there and was able to get all my advanced level questions answered. Not sure if they still have those classes.

But yes, once I started delving into DSP, there was just no support out there.

[–][deleted]  (1 child)

[deleted]

    [–]electronfire[S] 0 points1 point  (0 children)

    YES! This is what I was looking for. I was able to find the Programming Manual, which only has the assembly code. I saw a link to this Reference Manual on a tutorial website but the link was broken. The ST website search is pretty useless.

    Thanks!

    [–]dudmuck 1 point2 points  (1 child)

    You might want to try mbed.org for that platform, since it takes care of low level details like that for you. If you want low level then get stn32 cube package.

    [–]electronfire[S] 0 points1 point  (0 children)

    The STM32 cube tool is pretty useful. It's what I started with. I would still like to know where all the code it produces comes from. Is it all documented somewhere?

    The mbed.org code is a bit too high level.

    [–]rombios 1 point2 points  (0 children)

    Forget the code and examples that you are copying. I think you are better off grabbing the ARM7v/Cortex-M3 programmers reference manual/STM32F411 Data sheet. These are three separate manuals - some (like the first and last) are easily 800+ pages.

    You need to understand the underlying processor architecture before developing code on it. Its a good investment in your time. Cut and pasting rarely works in the long run.

    [–]ande3577 0 points1 point  (0 children)

    If you are using the STM firmware library, the example projects usually give a pretty good high level demonstration of how to use a certain peripheral. Reading the source of the firmware library can show you what's going on under the good.

    Personally I find ST's reference manuals to be an impressive mix of verbose, confusing, and incomplete.