|
SHULTZ ELECTRONICS 58 Smokey Crest Dr. Morgantown, WV 26508 1-888-474-8589
|
|
|
Home | Return Policy | About Us | Contact Us | Online Scanner | terms of service
|
|
PIC Micro: Handling Memory Boundaries
  
I have written a lot of code for Basic Stamp and PIC and continue to learn with
each and every project. Recently I had what may seem like a simple problem to
most people writing PIC code but in researching for an answer I found quite a
bit of difference in opinion as well as incorrect information on many websites.
Before going further I recommend that anyone serious about developing
embedded controls using the Microchip PIC micros should join the MIT PICLIST.
The folks on this site are wonderful. Many are full time developers in this field.
Calling lookup tables across memory boundaries.
I recently had a project that basically was a programmable timer / actuator.
I designed this timer to cycle a solid state relay. All parameters such as
the number of cycles, how long it was on, how long it was off an so on. I used
nearly every available bit of space in a 16F628. I knew of all the warnings
concerning placing my lookup tables at the beginning of program memory but
I had numerous lookup tables because I used programming prompts on an LCD.
Well, with the help of a local PIC enthusiast and very little from the
internet (PICLIST had much information but somewhat confusing at least for me).
he gave me a very direct and simple way to keep my lookup table calls from
getting lost so to speak. The following is a brief example of what I did in my
project and I hope it will help you in the future.
When calling a lookup table look to see in what memory page it is located in.
The PIC needs to know that once it makes a jump using the PCL you need to
remind it so to speak where it is located in reference to the memory pages.
If for instance you call a table from memory page 2 to a lookup table in page 1
at the beginning of the table do the following:
PRG_MSG_ALSEC
BCF PCLATH,0
BCF PCLATH,1
BCF PCLATH,2
ADDWF PCL,F
DT "ALARM DUR SECS",0
PCLATH 0 - 2 in this instance is set for page 0 if this were located in page 1
it would look like this.
PRG_MSG_ALSEC
BSF PCLATH,0
BCF PCLATH,1
BCF PCLATH,2
ADDWF PCL,F
DT "ALARM DUR SECS",0
SHULTZ
ELECTRONICS
58 Smokey Crest Dr.
Morgantown, WV 26508
PHONE: 1-888-474-8589
email: sales@shultzie.com
|
|
|
Copyright ©
2001-2008 by K-Factor Technologies Inc.
Powered by AgoraCart Gold. Maintained by Mister Ed at AgoraCart.com
|