Home arrow Support arrow Forums

Luminary Micro Forums

dalewheat

Expert Boarder
Click here to see the profile of this user

2006/10/26 22:02

EV-LM3S811 blinking LED in assembler

For the really hard core folk that want to get to the bare metal of the new Stellaris parts, here is a minimal program that will blink the user LED on the EV-LM3S811 board, in glorious ARM assembler code, which will compile under the uVision demo that is supplied with the evaluation kit:

; blink.s - blink user LED on Luminary Micro EV-LM3S811 (Cortex-M3)

AREA TEXT, CODE, READONLY
CODE16

; vector table

DCD 0x20002000
DCD Reset_Handler
DCD iloop
DCD iloop

; start the program here

Reset_Handler
EXPORT Reset_Handler

; initialize GPIO port C, pin 5 as output

RCGC2 EQU 0x400FE108 ; run-mode clock gating control 2
RCGC2_PORTC EQU 1 << 2 ; PORTC clock enable

ldr r0, =RCGC2

ldr r1, =RCGC2_PORTC
str r1, [r0]

GPIODIR_PORTC EQU 0x40006400
GPIO_PC5 EQU 1 << 5

ldr r0, =GPIODIR_PORTC

ldr r1, =GPIO_PC5
str r1, [r0]

GPIODATA_PORTC EQU 0x40006000

ldr r0, =GPIODATA_PORTC + (GPIO_PC5 << 2)

loop

ldr r1, =GPIO_PC5
str r1, [r0]

ldr r2, =1000000
1 subs r2, r2, #1
bne %1

ldr r1, =0
str r1, [r0]

ldr r2, =1000000
1 subs r2, r2, #1
bne %1

b loop ; and do it again

; an infinite loop in place of real exception handlers

iloop b iloop

; the end

END

[end-of-file]

Note that you will need to indent all the lines that don't start with a label, as this forum is protecting you from my code in its original beauty.

Questions? Comments? Let me know!

Dale

login or register to reply

englere

Gold Boarder
Click here to see the profile of this user

2006/10/30 10:07

Re:EV-LM3S811 blinking LED in assembler

Thanks for the example! I want to experiment with asm a little more.

I think you can use the "Code" button on the web page here to tell it not to mess up your indenting. When entering code in a message, try highlighting the code and then press the code button.

Here's a test - I want to see if this works:

Code:

 comment not indented label:     ; not indented   code1    indented 2 spaces     code2  indented 4 spaces lable2:    ; not indented

login or register to reply

dalewheat

Expert Boarder
Click here to see the profile of this user

2006/10/30 10:17

Re:EV-LM3S811 blinking LED in assembler

Oh, that's much better! Let me try this again, using the appropriate tools this time:

Code:

 blink.blink user LED on Luminary Micro EV-LM3S811 (Cortex-M3)     AREA    TEXTCODEREADONLY     CODE16     vector table     DCD    0x20002000     DCD    Reset_Handler     DCD    iloop     DCD    iloop     start the program here Reset_Handler     EXPORT Reset_Handler     initialize GPIO port Cpin 5 as output RCGC2            EQU 0x400FE108        run-mode clock gating control 2 RCGC2_PORTC        EQU 1 << 2            PORTC clock enable     ldr    r0, =RCGC2     ldr    r1, =RCGC2_PORTC     str    r1, [r0] GPIODIR_PORTC    EQU 0x40006400 GPIO_PC5        EQU 1 << 5     ldr    r0, =GPIODIR_PORTC          ldr    r1, =GPIO_PC5     str    r1, [r0] GPIODATA_PORTC    EQU 0x40006000     ldr    r0, =GPIODATA_PORTC + (GPIO_PC5 << 2) loop          ldr    r1, =GPIO_PC5     str    r1, [r0]     ldr    r2, =1000000 1    subs    r2r2#1     bne    %1     ldr    r1, =0     str    r1, [r0]          ldr    r2, =1000000 1    subs    r2r2#1     bne    %1     b    loop    ; and do it again     an infinite loop in place of real exception handlers iloop    b    iloop     the end     END [end-of-file]



Awesome! You might actually be able to cut+paste and get it to work! Thanks for the tip.

Dale

login or register to reply

petej

Fresh Boarder
Click here to see the profile of this user

2006/12/22 14:17

Re:EV-LM3S811 blinking LED in assembler

Dale,

Thanks for posting the code. Do you have any extra ASM to switch clocks to run the CPU at 50 MHz?

Out of interest, I created a very simple 'blinky' program in C using RV3 running the CPU at 50 MHz (SYSDIV _4) - the fastest I could get it to go using the LM Library calls was 541 KHz! Hence my request for ASM code to set the PLL.

Pete

login or register to reply

awneil

Senior Boarder
Click here to see the profile of this user

2008/05/16 16:55

Re:EV-LM3S811 blinking LED in assembler

This looks interesting - but how does one set up an Assembler project in code_suite?

The documentation seems to be entirely focussed on C/C++...

login or register to reply