I apologize for the relatively simplistic question re: RTFM material.
I am writing my first PIC '84 program.
It maps out to 01BE in length in terms of EPROM used for the program
(via the xxxx.LST output file from MPASM).
When adding YANF (Yet Another Neat Feature) ... (actually fix a bit of bad
logic) the length increases past this length (to 01AD for example).
The program now does not function. It appears that the if I have the
functioning program and continuously add nops to the program I can get to a
point where the program ceases to function, therefore no matter what the
code is ... even jumped over code ... the length itself creates the
symptom of crashing. Is not the maximum space for a '84 larger than this?
Or is a maximum program length to 200H - FFH (data registers + misc
|On Wed, 25 Jun 1997 22:29:54 +0200 "Michael Giuggio (Tel (860)763-6861)"
<PE.LSI.LEGO.DK> writes: Michael.Giuggio
>I apologize for the relatively simplistic question re: RTFM material.
>I am writing my first PIC '84 program.
>It maps out to 01BE in length in terms of EPROM used for the program
>(via the xxxx.LST output file from MPASM).
>When adding YANF (Yet Another Neat Feature) ... (actually fix a bit of
>logic) the length increases past this length (to 01AD for example).
>The program now does not function. It appears that the if I have the
>functioning program and continuously add nops to the program I can get
>point where the program ceases to function
What has probably happened is the extra code inserted has moved some of
the targets of computed jumps (usually used to access RETLW tables) out
of the first 256 program words. Unless you set the PCLATH register
otherwise, ADDWF PCL,f MOVWF PCL, etc. will always land in 256 word
"page" 0 (PC=00XX). For example, if you have a table at 0xFE:
; This instruction is at 0xFE now. Before adding a neat feature, it was
at ; 0xF0, and the program worked then.
gettabl addwf PCL,f
; Next instruction is at 0x100. This is bad.
If you call gettabl with 2 in W, expecting it to return 8, suprise. What
will actually happen (if PCLATH is still 0) is the PIC will jump to 0000,
starting the program over as if a reset had occurred. Not good.
I find it convenient to move all the RETLW tables and other targets of
computed gotos up to page 3 with an ORG h'300' directive, then set PCLATH
to 3 while initializing all the TRIS registers, etc. after reset. The
tables will then stay put if code is added or removed from the rest of
the program. Or you can put all the tables in first, then org the rest
of the program to 0x100.
ggio (Tel x6861)
I want to publically thank MKEITZ on the quick analysis. A sharp head.
I don't believe I ever would have found it....
(and I thought I was just getting comfortable with the PIC) <smiled sigh>.
Note: The '84 has only 1 real page ... 3rd page is not an option, I moved
computed jumps up in code space. Thanks again.
My Q condensed:
>>I am writing my first PIC '84 program.
>>When adding YANF (Yet Another Neat Feature) extending the length of
>> program made it not function.
His (Mike's?) Reply Condensed
Mike Keitz wrote:
Try this: it allows you to put your lookup tables wherever you want 'em.
You can even put them ON the edge of the first page and run over to the
MOVWF OFFSET ;MOVE
MOVLW HIGH BASEADD ;LOAD HIGH BYTE OF BASE ADDRESS INTO W
MOVWF PCLATH ;HIGH BASEADD INTO PC-LATCH
MOVLW LOW BASEADD ;LOAD LOW BYTE OF BASE ADDRESS INTO W
ADDWF OFFSET,W ;ADD OFFSET TO PC LOW
!!-->> BTFSC STATUS,C ;TEST FOR ROLL-OVER IN PC
!!-->> INCF PCLATH ;INCREMENT PCLATH IF ROLL-OVER DETECTED
MOVWF PCL ;LOW BASEADD INTO PCL
BASEADD RETLW B'01111101' ;1 - DUD! DUE TO MOD8 INCREMENTING TO 1
RETLW B'01111101' ;1
RETLW B'10101010' ;2
RETLW B'01101010' ;3
RETLW B'11100100' ;4
RETLW B'01111000' ;5
RETLW B'10101100' ;6
RETLW B'01101001' ;7
eric van es
cape town, south-africa
snipped original problem
Nice solution Eric, why didn't I think of that? ,don't answer ;-)
For a slight run time penalty this is a much neater way than some
of the macro based solutions I have seen.
Ray Gardiner Technical Director DSP systems Pty. Ltd. dsp-systems.comray
private email to:- netspace.net.au rayhttp://www.dsp-systems.com
More... (looser matching)
- Last day of these posts
- In 1997
, 1998 only
- New search...