Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

more caracters for message display

Status
Not open for further replies.

sarus

Newbie level 2
Joined
Dec 17, 2003
Messages
2
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
16
addwf problem

:| is there any hop to added more character (less then 32) to this program :
**broken link removed**
main page is her: **broken link removed**
thank u
 

hi,

i increased the lines of ( retlw B'0xxxxxxx' ) lines
but at specified number of lines it stopped and repeated from init.

After searching about this, i found that the problem from that line

addwf PCL,1

and i think the solution in these words :

Code:
          A Caution for PIC Assembly Programmers

There is a subtle point that you should keep in mind when writing
your assembly program for the PIC chip.  The program counter is
a 13-bit unsigned integer, but most of the commands that change
the value of the program counter provide fewer than 13 bits.
The commands CALL and GOTO provide only 11 bits, and any operation
such as ADDWF applied to PCL provides only 8 bits.  The remaining
of the 13 bits are obtained from the register PCLATH, which is
initially 0.  Hence, CALL and GOTO will operate only within
the first 2K of memory and the ADDWF PCL,f line that we use
to implement lookup tables works only in the first 256 words of
memory unless we explicitly set PCLATH to the proper value.
Since your program is not likely to exceed the 2K word limit,
we only need to worry about the situation where the ADDWF PCL,f line
of a lookup table gets pushed beyond the address 100h.  If you
add code to proto.asm and suddenly find that the program stops
working completely, it may be because you have pushed the ADDWF PCL,f
line used in the motor routine to a location beyond the 255 byte
limit.

To check for the problem, look at the .lst file that the assembler
produces and check every line of the form ADDWF PCL or ADDWF PCL,f
and check its address (the first number on the line; it is in
hexadecimal).  If that number is larger than 0FFh, the program
counter will be set to some address at the beginning of the
program instead of a few words further in the code where you want
it to go.  To fix the problem, insert the lines 

MOVLW 1
MOVWF PCLATH

somewhere just before you get ready to execute ADDWF PCL.  You
will also want to write the lines

MOVLW 0
MOVWF PCLATH

at the beginning of the main loop so that ADDWF PCL instructions
in the first 255 words of memory will work properly.

If your code gets so big that you find an ADDWF PCL instruction
at an address between 200h and 2FFh, you would use MOVLW 2 instead
of MOVLW 1, and so on.  Similarly, if your program should get so
big that a CALL or GOTO instruction either resides at a location
with an address beyond 7FFh or jumps to a location beyond 7FFh,
you will have to insert 

MOVLW n
MOVWF PCLATH

where n is the result of integer division of the target address
by 256.  (Drop the last 2 hexadecimal digits of the address being
jumped to or called to get n.)  Again, make sure that PCLATH is
properly set to the right value before every CALL and GOTO and
ADDWF PCL.  (You don't have to worry about CALL and GOTO instructions
even though PCLATH is being set to handle ADDWF PCL instructions if
the your program is less than 2048 instructions long.)

Note also that when ADDWF PCL executes, if the number in W and
PCL add to a number that is larger than 255, the carry bit gets
thrown away and the program counter will jump backwards instead
of forwards.  This is why the entire lookup table must not
straddle an address that is divisible by 256.

i will try -ISA- and post results.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top