Context Saving Issue - PIC

Status
Not open for further replies.

Suraj143

Active Member
In PIC16F630 does not have a common RAM area but datasheet suggests to do the following.
Code:
The user register, W_TEMP, must be defined
in both banks and must be defined at the same offset
from the bank base address

But when I define in same offset it gives an error saying
" : Duplicate label ("W_Temp" or redefining symbol that cannot be redefined)"
Code:
               cblock    48h
                Random
                X1,X2,X3,X4
                Row_Counter,Del_Count
                Offset_L,Offset_H
                P1,P2,P3
                R1,R2,R3
                Rotate_Count,Mask_L,Mask_R
                W_Temp,S_Temp,S_FSR,S_PCLATH        ; 5A,5B,5C,5D    ; ISR context registers
                endc
               
                cblock    0DAh
                W_Temp
                endc
 

Attachments

  • Context.JPG
    75.1 KB · Views: 253
Place it in the common area at 0x70. Or, place it at the beginning of your cblock and remember not yo use the same location in the next (all) bank(s). Or simply call it W_Temp2.

Mike.
Edit, missed the bit about no common area.
Also, if you're not using indirect addressing then you can use FSR as the location of W_Temp.
 
Hi, There is no common area 0x70 in this PIC16F630.
If I call it "W_Temp2" do I need to save & restore in context saving? Or just leave it alone & only save and restore only "W_Temp"...?
 
You just call it W_Temp2 and forget about it. If your code happens to be using bank2 when an interrupt comes along then it will use the bank 2 copy of the location. The context saving stays the same as in the datasheet.

Mike,
 
You just call it W_Temp2 and forget about it. If your code happens to be using bank2 when an interrupt comes along then it will use the bank 2 copy of the location. The context saving stays the same as in the datasheet.

Mike,

Many thanks.All understood.
 
Based on the datasheet, section 2.2.2, the RAM/Registers is common from 20 to 5F in both banks. Addressing it in bank1 (A0-DF) maps to bank0 (20-5F). Other PICs with larger RAM use the 70 to 7F region as common, but the 16F630 seems to map all 64 bytes as common, at least the way it reads in the datasheet....
 
The ram is common to both banks. Guess they copied the context save text from one without a common area.

Mike.
 
All you have to do to see how the Ram locations work is to View the File Registers once you have built your project etc.

Below is a View, File Registers using the old MPlab v8.92, expect its a similar thing in MPlabX.


 
This has already been said, but just to put it in simple pictures, here is the memory map from the Microchip datasheet;



JimB
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…