Live data from Hacker News

How to flash an LED: writing ARM assembly for an STM32 microcontroller

mcla.ug

51–60 of 68 posts

Re: How to flash an LED: writing ARM assembly for an STM32 microcontroller

#52
post #10

Earlier quoted context omitted.

Oh actually I was being sleepy and hadn't understood what you'd said! I hadn't realised you could do that actually, neat, thanks! So you could do `mov r1, #0x01000000` right? nice.

yup, some other constants are also loadable in one instr, of the form 0xXX00XX00, 0x00XX00XX, 0xXXXXXXXX where XX is any byte

[deleted]

Re: How to flash an LED: writing ARM assembly for an STM32 microcontroller

#53
Fantastic article, thanks for taking the time to write it up! I'm trying to learn about embedded systems at the moment and it feela like a super steep learning curve, really appreciate your post breaking everything down.

A little typo I think I spotted: ' So, to turn on our LED we want to set the BR8 field, and to turn it off, we want to set the BS8 field.'

Should this be: ' So, to turn on our LED we want to clear the BR8 field, and to turn it off, we want to set the BS8 field. '

Re: How to flash an LED: writing ARM assembly for an STM32 microcontroller

#54
post #3
post #2

Anybody got USB communication (CDC class) working on this platform without the proprietary libs?

no, i spent months on this, and the answer is no They use IP from synopsis, but synopsis refuses to allow their docs to be published so every manufacturer has to read them and regurgitate them into their own docs in their own words . In any case official STM docs are incomplete. See their driver source - it accesses undocumented registers and sets undocumented bits in documented regs. Without them the usb core will n…

I don't know what issues you are having with STM32 I2C, but I have done dozens of STM32 designs and have never had an issue and needed to bitbang it.

Re: How to flash an LED: writing ARM assembly for an STM32 microcontroller

#55
post #22

Earlier quoted context omitted.

Yes, probably! But you can do it yourself without one. Here is an example in C using libopencm3, that uses timers to trigger an interrupt used to flash LEDs https://github.com/libopencm3/libopencm3-examples/tree/maste...

that is basically a mini-os :)

You can set up a wakeup interrupt using a timer by moving a few values into a few registers. It doesn't require anything like an OS. Even tiny 8-bit microcontrollers can do this.

Re: How to flash an LED: writing ARM assembly for an STM32 microcontroller

#56

Fantastic article, thanks for taking the time to write it up! I'm trying to learn about embedded systems at the moment and it feela like a super steep learning curve, really appreciate your post breaking everything down. A little typo I think I spotted: ' So, to turn on our LED we want to set the BR8 field, and to turn it off, we want to set the BS8 field.' Should this be: ' So, to turn on our LED we want to clear th…

Thank you for the compliment ^_^ I'm glad you found the post helpful.

This isn't a typo, actually. If you look at the documentation of the BSRR register (which is screenshotted in the blog post), it says of BRy:

> These bits are write-only [...] [Setting to 1] Resets the corresponding ODRx bit

So setting BR8 in the BSRR clears the ORD8 bit in the output data register. Because our LED is active low, this turns the LED on.

The indirection can make this a little confusing, I hope this cleans it up!

Re: How to flash an LED: writing ARM assembly for an STM32 microcontroller

#57
post #35

Earlier quoted context omitted.

This is lovely to hear, I'm so glad it was helpful!

Not too familiar with the content of your post, but...I love your site design - great use of space, color & serif fonts!

I love getting compliments on my site design, thanks very much.

Re: How to flash an LED: writing ARM assembly for an STM32 microcontroller

#58
I have years of experience in asm programming with PIC processors, and my job is embedded software development. I got an STM32 development board a couple years ago to get my feet wet in ARM embedded development. I got completely bogged-down in setting up the development environment. It took me forever to get a blinking LED, and I spent an ungodly amount of time unsuccessfully trying to figure out how to change the rate based on a potentiometer input.

It was a very frustrating experience, but articles like this make me want to dive in and try again!

Re: How to flash an LED: writing ARM assembly for an STM32 microcontroller

#59

I have years of experience in asm programming with PIC processors, and my job is embedded software development. I got an STM32 development board a couple years ago to get my feet wet in ARM embedded development. I got completely bogged-down in setting up the development environment. It took me forever to get a blinking LED, and I spent an ungodly amount of time unsuccessfully trying to figure out how to change the ra…

Do you mean in assembly? If you just mean C, then if you’re already in embedded then I’d say a few years ago it was easy. These days it’s super easy - tools like STM32CubeMX will allow you to get even custom hardware up and running in no time.

It will even spit out multiple project types - everything from ARM Keil/MDK/uVision to just a simple makefile.

Re: How to flash an LED: writing ARM assembly for an STM32 microcontroller

#60
post #56

Fantastic article, thanks for taking the time to write it up! I'm trying to learn about embedded systems at the moment and it feela like a super steep learning curve, really appreciate your post breaking everything down. A little typo I think I spotted: ' So, to turn on our LED we want to set the BR8 field, and to turn it off, we want to set the BS8 field.' Should this be: ' So, to turn on our LED we want to clear th…

Thank you for the compliment ^_^ I'm glad you found the post helpful. This isn't a typo, actually. If you look at the documentation of the BSRR register (which is screenshotted in the blog post), it says of BRy: > These bits are write-only [...] [Setting to 1] Resets the corresponding ODRx bit So setting BR8 in the BSRR clears the ORD8 bit in the output data register. Because our LED is active low, this turns the LED…

Ahh I see now, thank you for teaching me. My mistake!

Do you happen to know of any great learning resources, basically more posts like you've written that go into lots of details and explain why things are done?

Thanks again!

Post reply on HN