Content originally posted in LPCWare by Chucky on Mon Sep 13 08:21:06 MST 2010
Hi there,
see below my humble efforts to create a (very) simple assembler program, that starts and toggles P0.7 on the LPC1114 ... at least that's what it should do.
The code assembles and links without error and also runs flawlessly in the simulator (all Keil µVision 4), it nicely sets Pin0.7 to output and toggles forever.
However it does not run on the chip once downloaded (tried with XPresso and flash magic, checksum provided).
So now I am at the end of my knowledge and it would be very cool if somebody from NXP (or anybody) could help me, veeeery coool :)
So here it goes, vectors included for completeness:
;*****************************************************************************
;try to blink a LED
;
;******************************************************************************
PRESERVE8
THUMB
AREARESET, CODE
bit_7EQU 0x00000080
PIN0_7EQU0x50000000 :OR: bit_7 ; pin mask for PIO0DATA_pin7
GPIO0DIREQU 0x50008000; port direction registers
EXPORT__Vectors ; ...
__Vectors DCD 0x10000200; Top of Stack
DCD Reset_Handler ; Reset_Handler
DCD Reset_Handler ; NMI Handler
DCD Reset_Handler ; Hard Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0xEFFFFBBD; Checksum = 2' complement of sum of location 0..6
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD Reset_Handler ; SVCall Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD Reset_Handler; PendSV Handler
DCD Reset_Handler ; SysTick Handler
; External Interrupts
DCD Reset_Handler ; 16+ 0: Wakeup PIO0.0
DCD Reset_Handler ; 16+ 1: Wakeup PIO0.1
DCD Reset_Handler ; 16+ 2: Wakeup PIO0.2
DCD Reset_Handler ; 16+ 3: Wakeup PIO0.3
DCD Reset_Handler ; 16+ 4: Wakeup PIO0.4
DCD Reset_Handler ; 16+ 5: Wakeup PIO0.5
DCD Reset_Handler ; 16+ 6: Wakeup PIO0.6
DCD Reset_Handler ; 16+ 7: Wakeup PIO0.7
DCD Reset_Handler ; 16+ 8: Wakeup PIO0.8
DCD Reset_Handler ; 16+ 9: Wakeup PIO0.9
DCD Reset_Handler ; 16+10: Wakeup PIO0.10
DCD Reset_Handler ; 16+11: Wakeup PIO0.11
DCD Reset_Handler ; 16+12: Wakeup PIO1.0
DCD 0 ; 16+13: Reserved
DCD Reset_Handler ; 16+14: SSP1
DCD Reset_Handler ; 16+15: I2C
DCD Reset_Handler ; 16+16: 16-bit Counter-Timer 0
DCD Reset_Handler ; 16+17: 16-bit Counter-Timer 1
DCD Reset_Handler ; 16+18: 32-bit Counter-Timer 0
DCD Reset_Handler ; 16+19: 32-bit Counter-Timer 1
DCD Reset_Handler ; 16+20: SSP0
DCD Reset_Handler ; 16+21: UART
DCD 0 ; 16+22: Reserved
DCD 0 ; 16+24: Reserved
DCD Reset_Handler ; 16+24: A/D Converter
DCD Reset_Handler ; 16+25: Watchdog Timer
DCD Reset_Handler ; 16+26: Brown Out Detect
DCD 0 ; 16+27: Reserved
DCD Reset_Handler ; 16+28: PIO INT3
DCD Reset_Handler ; 16+29: PIO INT2
DCD Reset_Handler ; 16+30: PIO INT1
DCD Reset_Handler ; 16+31: PIO INT0
EXPORT Reset_Handler
;-----------------------------------------------------
Reset_Handler ; this assembles to location 0x000000C1 (1 for thumb)
Main ; here we are :)
ldrr0, =GPIO0DIR
ldrr1, =bit_7 ; set bit 7 in direction register (all others will be cleared)
strr1, [r0]; set to output, store to direction register
ldrr0, =PIN0_7 ; load pinmask address for pin0_7, this is interesting
movs r2, #0
Loop
strr1, [r0]; set hi, r1 holds bit_7 (0x00000080)
strr2, [r0] ; set lo, r2 = 0
bLoop
END
;------------- that was it, see below the .hex output ----------
:020000040000FA
:1000000000020010C1000000C1000000C10000009B
:10001000000000000000000000000000BDFBFFEF3A
:10002000000000000000000000000000C10000000F
:100030000000000000000000C1000000C10000003E
:10004000C1000000C1000000C1000000C1000000AC
:10005000C1000000C1000000C1000000C10000009C
:10006000C1000000C1000000C1000000C10000008C
:10007000C100000000000000C1000000C10000003D
:10008000C1000000C1000000C1000000C10000006C
:10009000C1000000C10000000000000000000000DE
:1000A000C1000000C1000000C1000000000000000D
:1000B000C1000000C1000000C1000000C10000003C
:1000C0000348044901600448002201600260FCE723
:0C00D00000800050800000008000005004
:04000005000000C136
:00000001FF
Thanks for your help,
Chucky :)