Subject:
Re: [gnupic] Not being able to use variables on pic18fxx50
From:
Lope Vega ####@####.####
Date:
21 Aug 2008 15:14:23 -0000
Message-Id: <927420.32993.qm@web28201.mail.ukl.yahoo.com>
Hello again,
Thanks a lot, but it didn't do the trick either.
By looking at this a bit more indeep, while in relocatable mode I've noticed I can't use `udata_shr' (it throws an error about a not existing .udata_shr on the linker script, even when I gave that section a name to avoid it making use of the default value).
I still haven't been able to use variables reliably even with the most simple of the programs.
I'm pasting today, the program, and dumps from the chip's code and eeprom memories, and if somebody could tell me something about what's going on here, that would be great.
Here is the code:
;; setup processor and output format
list p=p18f4550,f=inhx32
include <p18f4550.inc>
config plldiv = 1
config fosc = intoscio_ec
config fcmen = off
config ieso = off
config pwrt = off
config bor = off
config borv = 0
config vregen = off
config wdt = off
config mclre = on
config lpt1osc = off
config pbaden = off
config ccp2mx = on
config stvren = off
config lvp = on
config icprt = off
config xinst = on
config debug = off
config cp0 = off
config cp1 = off
config cp2 = off
config cp3 = off
config cpb = off
config cpd = off
config wrt0 = off
config wrt1 = off
config wrt2 = off
config wrt3 = off
config wrtb = off
config wrtc = off
config wrtd = off
config ebtr0 = off
config ebtr1 = off
config ebtr2 = off
config ebtr3 = off
config ebtrb = off
udata
counter res 1
code 0
pagesel main
goto main
code
main
;; PORTB is all inputs, it just got an active-high switch
;; on RB4
clrf PORTB
movlw 0xff
movwf TRISB
;; PORTD is all outputs
clrf TRISD
banksel counter
restart
movlw 0x05
movwf counter
loop
;; has the switch been pressed?
btfsc PORTB, RB4
;; no, continue polling
goto loop
;; it's been, turn on the led @ RD0, just to have some feedback
bsf PORTD, RD0
debounce
;; has the switch been released?
btfss PORTB, RB4
;; no, poll some more
goto debounce
;; yes, turn the led @ RD0 off
bcf PORTD, RD0
decrement
;; decrement `counter', store result in that variable itself, and
;; and skip the instruction after this one if `counter == 0'
decfsz counter, f
goto loop
;; toggle led @ RD1
btg PORTD, RD1
;; goto start, where the counter gets set to 5 again, in theory
goto restart
end
This is a dump of the code's memory once burned:
ADDRESS DATA
-------- -----------------------------------------------
0x000000 81 6A FF 0E 93 6E 95 6A 00 01 05 0E 60 6F 81 B8
0x000010 07 EF 00 F0 83 80 81 A8 0B EF 00 F0 83 90 60 2F
0x000020 07 EF 00 F0 83 72 05 EF 00 F0
And this a dump of the epprom as well:
ADDRESS DATA
-------- -----------------------------------------------
0x000000 9F FF
If somebody could compile the above program and provide me with similar device's dumps that would be same as helpful as any explanation probably. The problem could very be due to the only program I could use for burning the chips on my freebsd: Broccoli18.
Many thanks.
--- El mar, 19/8/08, David Barnett ####@####.#### escribió:
> De: David Barnett ####@####.####
> Asunto: Re: [gnupic] Not being able to use variables on pic18fxx50
> Para: ####@####.####
> Fecha: martes, 19 agosto, 2008 12:37
> It looks like you're reserving memory in ROM and then
> accessing addresses in
> RAM. The RES directive allocates memory in the section
> you're defining, so
> look at UDATA and similar directives in the manual.
>
> David
>
> On Mon, Aug 18, 2008 at 12:20 PM, Lope Vega
> ####@####.#### wrote:
>
> > ...but I can't get the pic to "respect"
> and work with any variables other
> > than constants.
> >
> > This is an example program I wanted to start with:
> >
> > ...
>
> org 0
> >
> > counter res 2
> >
> > main:
> > ;; portd will be all outputs
> > clrf PORTD
> > clrf TRISD
> >
> > restart:
> > ;; give the memory address location `0x0'
> the value `5'
> > movlw 5
> > movwf 0x0
> >
> > loop:
> > ;; decrement this value till it's 0, what
> will cause the
> >
> > decfsz 0x0, f
> > goto loop
> >
> > btg PORTD, RD1
> > goto restart
> > end
> >
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
Regístrate ya - http://correo.yahoo.es