HomeArticlesProjectsBlogContact
Articles
Changing Micros
Colin Mitchell
Colin Mitchell
February 01, 2008
Make sure to subscribe to our newsletter and be the first to know the news.
  • 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(cont)DescriptionEquivalent Operation(s)(cont)Status
(file 03h)
ADDCFf,dAdd Carry to FileBTFSC
INCF
03h,0
f,d
Z
ADDDCFf,dAdd Digit Carry to FileBTFSC
INCF
03h,1
f,d
Z
BkBranchGOTOk-
BCkBranch on CarryBTFSC
GOTO
03h,0
k
-
BDCkBranch on Digit CarryBTFSC
GOTO
03h,1
k
-
BNCkBranch on No CarryBTFSS
GOTO
03h,0
k
-
BNDCkBranch on No Digit CarryBTFSS
GOTO
03h,1
k
-
BNZkBranch on No ZeroBTFSS
GOTO
03h,2
k
-
BZkBranch on ZeroBTFSC
GOTO
03h,2
k
-
CLRCClear CarryBCF03h,0-
CLRDCClear Digit CarryBCF03h,1-
CLRZClear ZeroBCF03h,2-
LCALLkLong CallBCF/BSF
BCF/BSF
CALL
0Ah,3
0Ah,4
k
LGOTOkLong GOTOBCF/BSF
BCF/BSF
GOTO
0Ah,3
0Ah,4
k
MOVFWfMove File to WMOVFf,0Z
NEGFf,dNegate FileCOMF INCFf,1
f,d
Z
SETCSet CarryBSF03h,0-
SETDCSet Digit CarryBSF03h,1-
SETZSet ZeroBSF03h,2-
SKPCSkip on CarryBTFSS03h,0-
SKPDCSkip on Digit CarryBTFSS03h,1-
SKPNCSkip on No CarryBTFSC03h,0-
SKPNDCSkip on No Digit CarryBTFSC03h,1-
SKPNZSkip on Non ZeroBTFSC03h,2-
SKPZSkip on ZeroBTFSS03h,2-
SUBCFf,dSubtract Carry from FileBTFSC DECF03h,0
f,d
Z
SUBDCFf,dSubtract Digit Carry from FileBTFSC DECF03h,1
f,d
Z
TSTFfTest FileMOVFf,1Z

Tags

#elektor
Colin Mitchell

Colin Mitchell

Expertise

electronics
writing
PIC-Chips

Social Media

instagramtwitterwebsite

Related Posts

TODO
PIC Elmer 160
March 06, 2012
© 2021, All Rights Reserved.

Quick Links

Advertise with usAbout UsContact Us

Social Media