one first step (on a 1000 miles journey)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

one first step (on a 1000 miles journey)

1,008 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Harrie Nijhof on Sat Nov 08 15:48:31 MST 2014
Dear people,

Below my first attempt to program a 1343. Guess what, it does not work. I can compile it, load the image (72 bytes) into the chip.
After restart, I can no longer enter the uart isp  bootloader so I think the chip accepts the checksum in 0x1C  and is in program mode.
But, nothing happens, pin 18 should go low, remains high, probably in a input pull-up state.
What do I do wrong?
And, has anyone an example like this for me? Perhaps a hexdump of a working image, or still better the output of a arm-none-eabi-objdump.
Just something that toggles a pin, any pin. Once, or in a sequence, I don''t care.
Looking forward..........
Harrie

.equ STACKINIT,0x10002000
.equ RESETVCTR,0x0000021
.equ GPIO2DIR,0x50028000
.equ GPIO2DATA,0x50023FFC
.equ LOOPTIME,6000000
.equ NULLCOMPL,0xEFFFDED6
.thumb
.syntax unified

.section.text
.org 0x0
_start: .global _start
vectors:
.word STACKINIT
.word _main + 1    @ reset vector (manually adjust to odd for thumb)
    .word _nmi_handler + 1  
    .word _hard_fault  + 1  
    .word _memory_fault + 1 
    .word _bus_fault + 1    
    .word _usage_fault + 1  
.word NULLCOMPL
_main:
mov r0, 0x10
mov r2, 0
ldr r1, =GPIO2DIR
str r1, [r0]@ GPIO2DIR is now 0x10: pin18 = output
ldr r1, =GPIO2DATA
str r1, [r2]

infinity:
b infinity
_dummy:                     @ if any int gets triggered, just hang in a loop
_nmi_handler:
_hard_fault:
_memory_fault:
_bus_fault:
_usage_fault:
        add r0, 1
        add r1, 1
        b _dummy                                                                                         
Labels (1)
0 Kudos
6 Replies

927 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Thu Nov 20 13:19:08 MST 2014

Quote: MarcVonWindscooting
One thing, that is different from other LPCs is the LPC13xx build-in 'USB drive' FLASH download capability, isn't it??



Nope, LPC15xx has USB-ISP, too (and UART and CAN)  :O

0 Kudos

927 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MarcVonWindscooting on Thu Nov 20 13:02:56 MST 2014

Quote: Harrie Nijhof

I am so sorry for you: A LPC13xx is a joy forever.


Yes, but that is true for LPC800, LPC1100, LPC... too  :p

One thing, that is different from other LPCs is the LPC13xx build-in 'USB drive' FLASH download capability, isn't it??
Who is using that? I guess it feels pretty much like using an 'mbed' board, doesn't it? I used an LPC17
mbed board for some time (before I made my own boards, that use UART ISP). Pretty cool, when your favourite OS can
FLASH your uC with a cp command, only 8-)
0 Kudos

927 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Harrie Nijhof on Sat Nov 15 05:58:05 MST 2014
Dear Marc,

Thank you so much for your remarks, tips, especially the two programs are very welcomed.
I did not use a linker script, I used arm-none-eabi-as , -ld, -objcopy series to compile to a binary image. Maybe not the fastes way, but for me they are the steady stepping rocks across the river.

I am so sorry for you: A LPC13xx is a joy forever.

>> For such a simple program, you don't need need a stack or the other exception handlers. Just zero these.<<
I supposed so allready, but in all examples I found these vectors were filled and so I copied them.

Again, thank you for your support,
greatings Harrie.
0 Kudos

927 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MarcVonWindscooting on Tue Nov 11 15:24:13 MST 2014
Hi Harrie,

my deep respect for you starting at the basics!
Pity, I don't have a LPC13xx.

For such a simple program, you don't need need a stack or the other exception handlers. Just zero these.
Also, I'd suggest you to use .thumb_func to let as know, what type (ARM or THUMB) the labels are. That's easier than
adding +1 . My opinion.
A nice short-cut for endless loop is b .

What's does your liker script look like?

EDIT: SCNR, here's a LPC812 LED program (plus some UART output) and a simple LD-script. Cortex-M0 instruction set - works on your uC to - you may pull out some snippets from this.
0 Kudos

927 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Harrie Nijhof on Sun Nov 09 12:09:20 MST 2014
Thank you IanB, str r1.[r0] was the culprit, Obviously it is : load this R WITH that stuff and store this stuff INTO that R

Somewere i found that with .syntax unified you can use mov instead movw , movt but I can not find the source of that. It works however.

I constructed this little program from a number of examples, the _main was a relic of one example.

I do not use lpcxpresso, I use the arm-none-eabi-as,  ld , objcopy  chain to assemble the given program and have written a set of python programs to upload the derived image. That way I feel I have a better insight in how things work.

Again, thank you, Harrie


0 Kudos

927 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by IanB on Sun Nov 09 03:45:38 MST 2014
STR R0,[R1]  not STR R1,[R0] stores the value of R0 into the address pointed to by R1.

and

to load the immediate value of 0x10 into R0 it is normally written MOVS R0,#0x10, though I can't think the assembler could possibly interpret what you wrote as anything other than a "load immediate" instruction.


(and doesn't lpcxpresso like to have the main routing called main: not _main: ?)
0 Kudos