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-c2014-01-07 04:51 AM
Hi Clive,
I would appreciate if you post some code of assembler concerning the WTDG in mixture with C Thanks Ted2014-01-07 09:18 AM
;*****************************************************************************
; In C code
; Prototype as
; extern void SystemReset(void);
; Call as
; SystemReset()
SystemReset PROC
EXPORT SystemReset
ldr r1, =0xE000ED0C ; NVIC Application Interrupt and Controller
ldr r0, =0x05FA0004 ; Magic
str r0, [r1, #0] ; Reset
b .
bx lr
ENDP ; SystemReset
;*****************************************************************************
; In C code
; Prototype as
; extern void KickWatchdog(void);
; Call as
; KickWatchdog()
KickWatchdog PROC
EXPORT KickWatchdog
ldr r0, =0x40003000 ; IWDG
movw r1, #0xAAAA
str r1, [r0, #0] ; IWDG_KR Reload / Kick
bx lr
ENDP ; KickWatchdog sourcer32@gmail.com
;*****************************************************************************
; In C code
; Prototype as
; extern void InitWatchdog(void);
; Call as
; InitWatchdog()
InitWatchdog PROC
EXPORT InitWatchdog
ldr r0, =0x40003000 ; IWDG
movw r1, #0x5555
str r1, [r0, #0] ; IWDG_KR Enable Access
movw r1, #6 ; /256
str r1, [r0, #4] ; IWD_PR Prescaler Register
movw r1, #0xFFF ; Reload value, reset default, writing for clarity, 768s
str r1, [r0, #8] ; IWD_RLR Reload Register
movw r1, #0xAAAA
str r1, [r0, #0] ; IWDG_KR Reload
movw r1, #0xCCCC
str r1, [r0, #0] ; IWDG_KR Enable
bx lr
ENDP ; InitWatchdog
;*****************************************************************************
2014-01-16 02:46 AM
Hi Clive,
thanks for the example. I want to apology not having answered quickly, but had to go abroad immediately. The code works smoothly. Could you please attach some other code in asm for stm32f4( for example initiating interfaces like DCMI or something else), or give some useful links to practice asm in stm32f4.? Thanks Ted2014-01-17 12:10 PM
Assembly coding isn't much in vogue these days, I don't see much dealing with the Cortex-Mx series, and nothing much to speak of for the STM32Fx.
For an ARM Assembler perspective, currently I might suggest Hohl or Gibson, the international versions are very good, and cheap, if you can tolerate waiting for the Indians to ship it to you. 30 day ship time apparently means we will ship it after 30 days, and transit time is in addition to that. They managed to print my Name and City on the label, and thankfully the USPS figured it out.http://www.abebooks.com/servlet/SearchResults?sts=t&tn=arm+assembly+language
Hohl is quite recent, but at the same time rather dated (late to market), focusing on ARM7/9, I wouldn't pay the >$60 stateside price for the hard cover, must be on some college reading list. Cockerell is rather old too, and targeted originally at the Acorn/BBC/Archimedes, but he has posted a free version, and hosts a PDF.http://www.peter-cockerell.net/aalp/
Beyond that I'd recommend looking at compiler output, either at .LST files generated, or creating them from ELF objects using tools like FromELF (Keil) or objdump (GNU/GCC)2014-01-21 09:51 AM
Hi Clive,
thanks. Ted2014-01-21 10:47 AM
http://shop.oreilly.com/product/9781118788943.do
http://www.toves.org/books/armsub/
http://www.eng.auburn.edu/~nelson/courses/elec5260_6260/ARM_AssyLang.pdf