Baking Pi, OK 03, B+ - Raspberry Pi Forums
i have 2 questions:
firstly, in setgpiofunction function says add 4 gpio address, stored in r0, each loop, write directly address in r0. worked setting r3 0, adding 4 r3 each loop, writing address in r0 offset of r3: why didn't first work? not same thing?
secondly, tutorial said include code didn't work until removed section.
firstly, in setgpiofunction function says add 4 gpio address, stored in r0, each loop, write directly address in r0.
code: select all
functionloop: cmp r2,#9 subhi r2,#10 addhi r0,#4 bhi functionloop //stuff str r1,[r0]
code: select all
functionloop: // address didn't work. cmp r2,#9 subhi r2,#10 addhi r3,#4 bhi functionloop // stuff str r1,[r0,r3]
secondly, tutorial said include
code: select all
pinbank .req r3 lsr pinbank,pinnum,#5 lsl pinbank,#2 add gpioaddr,pinbank .unreq pinbank
interestingly tryed follow tutorial pi 1 b+ , can select pins of pins dont work....
atleast compile program, can try code register 3 fix?
gpio api: 3led on ports 25,6,18 turn on , off ~1sec delay:
atleast compile program, can try code register 3 fix?
gpio api:
code: select all
/* function normal gpio address */ .globl getgpioaddress /* accessable everyone*/ getgpioaddress: /* label */ ldr r0,=0x20200000 /* load gpio address r0 */ mov pc,lr /* return main programm */ /*---------------------------------------------------------------------------------*/ /* function sets gpio pin function */ /* r0 contains gpio address, r1 contains function code, r2 contains pin number */ .globl setgpiofunction /* accessable */ setgpiofunction: /* label */ cmp r0,#53 /* failsafe (if desired pin >=53 yes 53 because of internal pins!) */ cmpls r1,#7 /* failsafe (if desired mode >=7) */ movhi pc,lr /* return main programm( if in last compare a>b(register 0)>53 etc..)*/ push {lr} /* save lr(link register) stack */ mov r2,r0 /* save gpio bus address r2 */ bl getgpioaddress /* gpioaddress r0 (function coded r0) bl updates link register call method*/ functionloop$: /* label helper function because devision slow*/ cmp r2,#9 /* compare pinnumber 9 pin number 0-9 */ subhi r2,#10 /* if compare a>b pinnumber -10 */ addhi r0,#4 /* if compare a>b gpio address +4 */ bhi functionloop$ /* if compare a>b go loop start */ add r2, r2,lsl #1 /* faster multiplication 3 */ lsl r1,r2 /* shift because want set pin number */ str r1,[r0] /* store r1 register 0 */ pop {pc} /* return mov pc,lr */ /*---------------------------------------------------------------------------------*/ .globl setgpio setgpio: pinnum .req r0 pinval .req r1 cmp pinnum,#53 movhi pc,lr push {lr} mov r2,pinnum .unreq pinnum pinnum .req r2 bl getgpioaddress gpioaddr .req r0 pinbank .req r3 lsr pinbank,pinnum,#5 lsl pinbank,#2 add gpioaddr,pinbank .unreq pinbank , pinnum,#31 setbit .req r3 mov setbit,#1 lsl setbit,pinnum .unreq pinnum teq pinval,#0 .unreq pinval streq setbit,[gpioaddr,#40] strne setbit,[gpioaddr,#28] .unreq setbit .unreq gpioaddr pop {pc}
code: select all
.section .init .globl _start _start: /*-fehler: 26,21,20-----------------------------------*/ loop$: /*---------------------------------------------------------------------------------*/ pinnum .req r0 pinfunc .req r1 mov pinnum,#25 mov pinfunc,#1 bl setgpiofunction .unreq pinnum .unreq pinfunc /*---------------------------------------------------------------------------------*/ pinnum .req r0 pinval .req r1 mov pinnum,#25 mov pinval,#1 bl setgpio .unreq pinnum .unreq pinval /*---------------------------------------------------------------------------------*/ mov r2,#0x3f0000 wait1$: sub r2,#1 cmp r2,#0 bne wait1$ /*---------------------------------------------------------------------------------*/ pinnum .req r0 pinfunc .req r1 mov pinnum,#6 mov pinfunc,#1 bl setgpiofunction .unreq pinnum .unreq pinfunc /*---------------------------------------------------------------------------------*/ pinnum .req r0 pinval .req r1 mov pinnum,#6 mov pinval,#1 bl setgpio .unreq pinnum .unreq pinval /*---------------------------------------------------------------------------------*/ mov r3,#0x3f0000 wait2$: sub r3,#1 cmp r3,#0 bne wait2$ /*---------------------------------------------------------------------------------*/ pinnum .req r0 pinfunc .req r1 mov pinnum,#18 mov pinfunc,#1 bl setgpiofunction .unreq pinnum .unreq pinfunc /*---------------------------------------------------------------------------------*/ pinnum .req r0 pinval .req r1 mov pinnum,#18 mov pinval,#1 bl setgpio .unreq pinnum .unreq pinval /*---------------------------------------------------------------------------------*/ mov r4,#0x3f0000 wait3$: sub r4,#1 cmp r4,#0 bne wait3$ pinnum .req r0 pinval .req r1 mov pinnum,#25 mov pinval,#0 bl setgpio .unreq pinnum .unreq pinval mov r4,#0x3f0000 wait4$: sub r4,#1 cmp r4,#0 bne wait4$ pinnum .req r0 pinval .req r1 mov pinnum,#6 mov pinval,#0 bl setgpio .unreq pinnum .unreq pinval mov r4,#0x3f0000 wait5$: sub r4,#1 cmp r4,#0 bne wait5$ pinnum .req r0 pinval .req r1 mov pinnum,#18 mov pinval,#0 bl setgpio .unreq pinnum .unreq pinval mov r4,#0x3f0000 wait6$: sub r4,#1 cmp r4,#0 bne wait6$ b loop$
raspberrypi
Comments
Post a Comment