Hi Rob,
The first key part is if you intended to use the normal GPIO and need
to access the L3 bus, you'll need to enable access by STANDBY_INIT in
the SYSCFG register. I wasted alot of time trying to access main
system memory until I stumbled on this bit.
Here is some rough code I had laying around that would loop and toggle
a GPIO using the eCAP counter. You'll need to disable the eCAP loop
code or configure eCAP yourself. It's ugly, I'd clean it up if I had
time. Hopefully it'll at least give you ideas as to what to do.
Push and pop are macros I wrote to simulate a stack:
#define STACK_TOP (0x2000 - 4)
#define STACK_BOTTOM (0x2000 - 0x200)
.macro stack_init
mov sp, STACK_BOTTOM
.endm
///////////////////////////////////////////////////////////////
// Stack Push
// reg - starting register to push
// cnt - number of registers to push starting at reg
///////////////////////////////////////////////////////////////
.macro push
.mparam reg, cnt
sbbo reg, sp, 0, 4*cnt
add sp, sp, 4*cnt
.endm
///////////////////////////////////////////////////////////////
// Stack Pop
// reg - starting register to pop
// cnt - number of registers to pop starting at reg
///////////////////////////////////////////////////////////////
.macro pop
.mparam reg, cnt
sub sp, sp, 4*cnt
lbbo reg, sp, 0, 4*cnt
.endm
///////////////////////////////////////////////////////////////
// GPIO test
//
// @param R1 number of loops to run
///////////////////////////////////////////////////////////////
gpio_test:
push lr, 1
push r1, 4
mov R3, R1
// Set OE to output for GPIO 33 & 34
mov r4, \#0x4804c100
LBBO R1, r4, 0x34, 4
mov R2, \#0xfffffff9
and R1, R1, R2
SBBO R1, r4, 0x34, 4
gpio_loop:
LBBO R1, r4, 0x3c, 4
and R1, R1, R2
SBBO R1, r4, 0x3c, 4
LBBO R1, r4, 0x3c, 4
or R1, R1, \#0x6
SBBO R1, r4, 0x3c, 4
sub R3, R3, \#1
QBGE gpio\_end, R3, \#0 // quick branch if 0 > r3
//QBA gpio\_loop
GPIO_POLL_IRQ:
lbco r1, c3, 0x2e, 2
QBBS GPIO_CLEAR_CONT, r1.w0, 6
QBA GPIO_POLL_IRQ
GPIO_CLEAR_CONT:
mov r1, 0xff
SBCO r1, c3, 0x30, 2
QBA gpio_loop
gpio_end:
pop r1, 4
pop lr, 1
ret
- Kyle
www.kylemanna.com