neoaspilet11
Full Member level 5
- Joined
- Sep 29, 2005
- Messages
- 277
- Helped
- 29
- Reputation
- 56
- Reaction score
- 8
- Trophy points
- 1,298
- Location
- Cebu, Philippines
- Activity points
- 4,048
pclath
Hello Everybody,
I got this funny experience in manipulating the PCL and PCLATH registers of PIC.
I have huge data table in a magnitude of 800+ memory locations. A revise edition of my data table has more than 3000 memory locations. But I have not coded it yet.
The problem goes like this
WREG = 7C; before entering to Data Table
PCLATH = 00h
Table addwf PCL,1 ; PCL =PCL + w Address =0x83
....
....
....
retlw XX ; Address = 00FF
retlw YY ; Address = 0100
retlw ZZ ; Address = 0101
.....
.....
You see when the ADD instruction is executed, PCL = 100h or it overflows! The MPU simply execute the RESET vector instead of executing Address 0100h. Hehe It took me 30 minutes to realize what was my mistake.
Although I have a solution to this problem by simply dividing the Data table by several tables and manipulating the Value to be added to PCL, PCLATH and PCL I still have some questions.
1.) Is it not automatic when PCL overflows by addtion instruction to PCL, PCLATH will be incremented ?
2.) Is there any other way to implement the TABLE by not dividing it to several tables? (It should be noted that the value to be added to PCL is more than 8 bits. This means an appropriate PCLATH manipualtion must also be done.)
3.) Is it possible to manipulate both PCL and PCLATH in just one instruction by just adding value to it?
Thanks for your ideas.
Hello Everybody,
I got this funny experience in manipulating the PCL and PCLATH registers of PIC.
I have huge data table in a magnitude of 800+ memory locations. A revise edition of my data table has more than 3000 memory locations. But I have not coded it yet.
The problem goes like this
WREG = 7C; before entering to Data Table
PCLATH = 00h
Table addwf PCL,1 ; PCL =PCL + w Address =0x83
....
....
....
retlw XX ; Address = 00FF
retlw YY ; Address = 0100
retlw ZZ ; Address = 0101
.....
.....
You see when the ADD instruction is executed, PCL = 100h or it overflows! The MPU simply execute the RESET vector instead of executing Address 0100h. Hehe It took me 30 minutes to realize what was my mistake.
Although I have a solution to this problem by simply dividing the Data table by several tables and manipulating the Value to be added to PCL, PCLATH and PCL I still have some questions.
1.) Is it not automatic when PCL overflows by addtion instruction to PCL, PCLATH will be incremented ?
2.) Is there any other way to implement the TABLE by not dividing it to several tables? (It should be noted that the value to be added to PCL is more than 8 bits. This means an appropriate PCLATH manipualtion must also be done.)
3.) Is it possible to manipulate both PCL and PCLATH in just one instruction by just adding value to it?
Thanks for your ideas.