2013-04-30 03:02 PM
I've made up a board and embedded a STM32F4 on it. I want example assembly code to compile and upload to the chip. I can't find any on the entire internet for a Cortex-M4. Does anyone have a link to a generic GPIO blinking program I can run to get myself started, like a hello world in assembly for the STM32?
#assembly-gpio-code-example-corte #mixing-assm-code-with-c2013-04-30 03:52 PM
2013-05-01 01:11 AM
While I appreciate you want something simple to begin with, you really ought to consider the CMSIS and ST Peripheral Library. Apart from anything else, use of the library will greatly increase your chances of getting useful support here. Using the peripheral library does not prevent you from writing efficient code.
2013-05-01 06:11 AM
I wouldn't discourage anyone from trying to use assembly, the Cortex-M3 is designed for easy C usage, but being able to read/write assembler is very useful, and a skill many do not possess. I'll post some example if it helps, and take questions.
2013-05-01 08:03 AM
I wouldn't discourage anyone from trying to use assembly, the Cortex-M3 is designed for easy C usage, but being able to read/write assembler is very useful, and a skill many do not possess. I'll post some example if it helps, and take questions.
I do partially agree. I do know, and agree it is essential, enough M3 assembly to read the disassembly, but would never attempt to get fluent enough to write it beyond possibly a very small routine. if the OP is, in effect, saying ''I do not know C'' my absolute recommendation is, forget about the M3 till you have learned C. Erik2013-05-01 08:05 AM
''Examples'' ... Yes please. ''Discourage'' not intended ... but I stand by my comments.
2013-05-01 08:10 AM
I look at C vs ASM as a ''time to market'' thing.
With C, I can get to the minimum viable product in much less time than using ASM with less defects and better readability.the microcontrollers offered these days have large code and data space so there is less need of hand tuned firmware.ASM is used only when there is a need to optimize some portion of code.Agile Development suggests that optimization should not be done until one measures and determines that there is a need.So, last time I used ASM was two years ago! The C/C++ compilers are good.2013-05-01 08:18 AM
I know C++, FORTRAN, JAVA, HTML, BASIC ... I even taught a class on C at ITT Tech. My situation is the STM32 will be used to input Analog signals and output PWMs. So the STM32 is like a closed loop feedback path. The code will primarily be interrupt service routines, that take digitally processed signals in real time and use that info to modulate digital PWMs for output. Timing need to be under 50us for everything. Is there a library for high power applications?
I have another question though. I see my sample code will starts at 0x00000000, while my flash memory starts at 0x08000000. The Cortex-M? literature says my vector table should start at 0x00000000, but I read that for STM32 the vector table starts at 0x08000000. The flash starts at 0x08000000. How is this? Is it shadowed at 0x00000000? Is this part of the flash ART? Its a huge idioscncracy I have yet found an explanation for.2013-05-01 09:52 AM
The zero mapping/shadowing is defined by the BOOTx pins, a behaviour outside the core defined by the implementer, in this case ST.
After boot you can reprogram SCB->VTOR to change the vector table address, based on the vector usage by ST, this needs to fall on a 512 byte boundary. For the F4 see RM0090 Rev 4 see ''2.4 Boot Configuration'', and ''8.2.1 SYSCFG memory remap register (SYSCFG_MEMRMP)''2013-05-01 10:15 AM
OK, that sheds a better light.
I would still start up everything in C using CMSIS which will do all the setup; the stuff that is not your core competence.Then, after all is setup and good to go, your main loop can venture off into ASM land.easier to understand C->ASM calling convention than do all the startup stuff.