Live data from Hacker News

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

mcla.ug

11–20 of 68 posts

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

#11
post #10
post #7

Earlier quoted context omitted.

This is true! If I was writing something to be optimal speed- and size-wise, I'd do that. I think I just liked the consistency with the other parts of the code where using both was necessary :)

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

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

#12
post #9
post #3

Earlier quoted context omitted.

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…

Can you point to where the undocumented registers are used in the source? I don't see anything obvious that fits that definition in: https://github.com/STMicroelectronics/STM32CubeF4/tree/maste... (I've chosen the version for STM32F4 arbitrarily; if there's something similar in one of their other USB support libraries, feel free to point to that instead.)

a few bits used here are not in the docs: https://github.com/STMicroelectronics/STM32CubeF4/blob/maste...

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

#14
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

Do you not need the usual LSL, or does the assembler take care of that?

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

#15

Earlier quoted context omitted.

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

Do you not need the usual LSL, or does the assembler take care of that?

it does, yes

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

#16
post #9

Earlier quoted context omitted.

Can you point to where the undocumented registers are used in the source? I don't see anything obvious that fits that definition in: https://github.com/STMicroelectronics/STM32CubeF4/tree/maste... (I've chosen the version for STM32F4 arbitrarily; if there's something similar in one of their other USB support libraries, feel free to point to that instead.)

a few bits used here are not in the docs: https://github.com/STMicroelectronics/STM32CubeF4/blob/maste...

That's a 2000-line file. What part of it are you referring to?

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

#18

Is there a better way to sleep/delay other than what basically seems like 100% CPU usage in a subtraction loop?

if you have an OS, yes

You don't need an OS to do more advanced or efficient sleeping. You could have one of the timer peripherals generate an interrupt on a regular basis, and then put the chip in a lower power sleep mode in between interrupts.

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

#19

Is there a better way to sleep/delay other than what basically seems like 100% CPU usage in a subtraction loop?

Nearly every microcontroller has at least one free-running timer that can be used to either reset or wake the processor, if you care about power.

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

#20

Is there a better way to sleep/delay other than what basically seems like 100% CPU usage in a subtraction loop?

The other approach to delay's (keep in mind, that there is no other process to yield the CPU too) is to use a timer (a peripheral of the micro controller).

This would take a fair bit more code to configure the timer, and setup an interrupt to handle the timer.

Post reply on HN