Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
At some stage in your work you will have to
change micro's. It may be to change from a "One Time Programmable" chip
to a flash version, or it may be to a chip with more features, such as
Analogue to Digital Conversion.
Or it may be to our low-cost MCV08A - with 1k of program, 1 - ADC and
precision 0.6v reference.
Changing from one chip to another is not easy as the files (the files
you use to store temporary data during the running of a program) start
at different addresses.
That's why this information is important, so you can plan ahead and make
the transfer as simple as possible.
At the start of a program we use "equates."
This is simply assigning each name used in the program, to a
file.
Suppose we create a delay sub-routine. Suppose it requires two files. We
call them: "del1" and "del2" (for delay1 and delay2).
For a PIC micro with the code: MCV08A, the first available file is 0Ah.
For a PIC12F629, the first available file is 20h and for a PIC12F508/9,
it is 07h, as shown in the file map:
Since the General Purpose Registers start
at different locations, del1 and del2 will be file 0Ah, and 0Bh for the
MCV08A and different numbers for the other two chips. To save moving all
the files when changing chips, we have a simple way to make all files
"automatically change."
Up to now, we have advocated using "equates" to assign each file-name to
one of the General Purpose Registers, thus:
timera equ 20h ;general purpose timer
timerb equ 21h ;general purpose timer
timerc equ 22h ;general purpose timer
timerd equ 23h ;general purpose timer
note_select equ 24h ;selection of note
note_tone equ 25h ;frequency of note
note_length equ 26h ;length of note
note_tempo equ 27h ;tempo of song
random equ 28h ;random number |
All the file numbers will have to be moved when
changing micro's. To save this, and prevent any mistakes we use cblock. This is a directive
used for defining files in a compact way. The format of cblock is:
cblock 0x20 ;define the start of the files. The first
"file" or "register" for a 12F629 is 20h
timera
;this will be file 20h
timerb
;this will be file 21h
timerc
;this will be file 22h etc etc etc
endc
Each file on the list will be allocated the next General Purpose
Register.
To make cblock universal, we use:
cblock RAMStart
The assembler will automatically equate
the names you have used for your sub-routines with the start of the General Purpose
Registers. For MCV08A, this will be 0Ah, and for PIC12F629 it will be
20h, etc.
cblock becomes:
cblock RAMStart
timera
timerb
timerc
timerd
note_select
note_tone
note_length
note_tempo
random
endc |
The next things to consider are the different features of each chip:
1. The MCV08A, PIC12F629 and PIC12C509 has 1k of program-space, the
PIC12C508A has 512 spaces.
2. The MCV08A and PIC12C508/9 has no EEPROM and cannot store data when
the chip is turned off.
3. All chips have the same pin numbers for GP0, GP1, GP2, GP3, GP4 and
GP5. All outputs sink and source 25mA max.
4. THE STACK
MCV08A and PIC12C508/9 has a 2-stack. This allows a call to be made to a
sub-routine and the sub-routine can make a call to another sub-routine.
PIC12F629 has an 8-stack and any programs to be transferred from this
chip to either of the others will have to be carefully checked to
determine how the calls have been made.
5. MCV08A has no interrupt feature. For instance, if you want the micro
to go to "isr" (Interrupt Service Routine) when it overflows from FF to
00, do not use
the MCV08A.
cvcc
12-Bit PSEUDO Instruction
Mnemonics
Mnemonic
|
Description
|
Equivalent
Operation(s)
|
Status
(file 03h)
|
ADDCF
|
f,d
|
Add Carry to File
|
BTFSC
INCF
|
03h,0
f,d
|
Z
|
ADDDCF
|
f,d
|
Add Digit Carry to File
|
BTFSC
INCF
|
03h ,1
f,d
|
Z
|
B
|
k
|
Branch
|
GOTO
|
k
|
-
|
BC
|
k
|
Branch on Carry
|
BTFSC
GOTO
|
03h ,0
k
|
-
|
BDC
|
k
|
Branch on Digit Carry
|
BTFSC
GOTO
|
03h ,1
k
|
-
|
BNC
|
k
|
Branch on No Carry
|
BTFSS
GOTO
|
03h ,0
k
|
-
|
BNDC
|
k
|
Branch on No Digit Carry
|
BTFSS
GOTO
|
03h ,1
k
|
-
|
BNZ
|
k
|
Branch on No Zero
|
BTFSS
GOTO
|
03h ,2
k
|
-
|
BZ
|
k
|
Branch on Zero
|
BTFSC
GOTO
|
03h ,2
k
|
-
|
CLRC
|
|
Clear Carry
|
BCF
|
03h ,0
|
-
|
CLRDC
|
|
Clear Digit Carry
|
BCF
|
03h ,1
|
-
|
CLRZ
|
|
Clear Zero
|
BCF
|
03h ,2
|
-
|
LCALL
|
k
|
Long Call
|
BCF/BSF
BCF/BSF
CALL
|
0Ah,3
0Ah,4
k
|
|
LGOTO
|
k
|
Long GOTO
|
BCF/BSF
BCF/BSF
GOTO
|
0Ah,3
0Ah ,4
k
|
|
MOVFW
|
f
|
Move File to W
|
MOVF
|
f,0
|
Z
|
NEGF
|
f,d
|
Negate File
|
COMF
INCF
|
f,1
f,d
|
Z
|
SETC
|
|
Set Carry
|
BSF
|
03h,0
|
-
|
SETDC
|
|
Set Digit Carry
|
BSF
|
03h ,1
|
-
|
SETZ
|
|
Set Zero
|
BSF
|
03h ,2
|
-
|
SKPC
|
|
Skip on Carry
|
BTFSS
|
03h ,0
|
-
|
SKPDC
|
|
Skip on Digit Carry
|
BTFSS
|
03h ,1
|
-
|
SKPNC
|
|
Skip on No Carry
|
BTFSC
|
03h ,0
|
-
|
SKPNDC
|
|
Skip on No Digit Carry
|
BTFSC
|
03h ,1
|
-
|
SKPNZ
|
|
Skip on Non Zero
|
BTFSC
|
03h ,2
|
-
|
SKPZ
|
|
Skip on Zero
|
BTFSS
|
03h ,2
|
-
|
SUBCF
|
f,d
|
Subtract Carry from File
|
BTFSC
DECF
|
03h ,0
f,d
|
Z
|
SUBDCF
|
f,d
|
Subtract Digit Carry from File
|
BTFSC
DECF
|
03h ,1
f,d
|
Z
|
TSTF
|
f
|
Test File
|
MOVF
|
f,1
|
Z
|
|