If you need assistance, please send an email to forum at 4hv dot org. To ensure your email is not marked as spam, please include the phrase "4hv help" in the subject line. You can also find assistance via IRC, at irc.shadowworld.net, room #hvcomm.
Support 4hv.org!
Donate:
4hv.org is hosted on a dedicated server. Unfortunately, this server costs and we rely on the help of site members to keep 4hv.org running. Please consider donating. We will place your name on the thanks list and you'll be helping to keep 4hv.org alive and free for everyone. Members whose names appear in red bold have donated recently. Green bold denotes those who have recently donated to keep the server carbon neutral.
Special Thanks To:
Aaron Holmes
Aaron Wheeler
Adam Horden
Alan Scrimgeour
Andre
Andrew Haynes
Anonymous000
asabase
Austin Weil
barney
Barry
Bert Hickman
Bill Kukowski
Blitzorn
Brandon Paradelas
Bruce Bowling
BubeeMike
Byong Park
Cesiumsponge
Chris F.
Chris Hooper
Corey Worthington
Derek Woodroffe
Dalus
Dan Strother
Daniel Davis
Daniel Uhrenholt
datasheetarchive
Dave Billington
Dave Marshall
David F.
Dennis Rogers
drelectrix
Dr. John Gudenas
Dr. Spark
E.TexasTesla
eastvoltresearch
Eirik Taylor
Erik Dyakov
Erlend^SE
Finn Hammer
Firebug24k
GalliumMan
Gary Peterson
George Slade
GhostNull
Gordon Mcknight
Graham Armitage
Grant
GreySoul
Henry H
IamSmooth
In memory of Leo Powning
Jacob Cash
James Howells
James Pawson
Jeff Greenfield
Jeff Thomas
Jesse Frost
Jim Mitchell
jlr134
Joe Mastroianni
John Forcina
John Oberg
John Willcutt
Jon Newcomb
klugesmith
Leslie Wright
Lutz Hoffman
Mads Barnkob
Martin King
Mats Karlsson
Matt Gibson
Matthew Guidry
mbd
Michael D'Angelo
Mikkel
mileswaldron
mister_rf
Neil Foster
Nick de Smith
Nick Soroka
nicklenorp
Nik
Norman Stanley
Patrick Coleman
Paul Brodie
Paul Jordan
Paul Montgomery
Ped
Peter Krogen
Peter Terren
PhilGood
Richard Feldman
Robert Bush
Royce Bailey
Scott Fusare
Scott Newman
smiffy
Stella
Steven Busic
Steve Conner
Steve Jones
Steve Ward
Sulaiman
Thomas Coyle
Thomas A. Wallace
Thomas W
Timo
Torch
Ulf Jonsson
vasil
Vaxian
vladi mazzilli
wastehl
Weston
William Kim
William N.
William Stehl
Wesley Venis
The aforementioned have contributed financially to the continuing triumph of 4hv.org. They are deserving of my most heartfelt thanks.
Registered Member #3546
Joined: Tue Dec 28 2010, 08:24AM
Location: Pittsburgh, PA
Posts: 18
I have this terrible tendency to try to make things not suitable for 8-bit PICs. I also only program PICs in assembly; I know what you're going to say.....
Anyways I have a small problem. When I write my programs I have a tendency to go over 256 lines of code. This is fine because from my understanding the PIC16F8xx family that I typically use has four times this code memory. Unfortunately if your code goes into one of the later program code banks and you attempt to adjust the code line for something such as a look up table it throws me into that location in the first bank. How do I ensure that I stay in the second or third or four memory bank without having to leave all my look up tables at the top of my code. Honestly I asked my professor that question and he didn't know how, hopefully one of you guys has figured this problem out in the past.
Registered Member #30
Joined: Fri Feb 03 2006, 10:52AM
Location: Glasgow, Scotland
Posts: 6706
Lookup tables that cross page boundaries are a classic PIC f***-up. Using the ORG statement helps, but you also have to set the high bits of the program counter appropriately.
Once you've started playing with PCLATH, you also have to save it and restore it in your ISR, if you're using interrupts. (Took me a long time to figure that one out.)
Here's part of a lookup table routine I wrote earlier, for a keyboard scanner implemented on a PIC16F870. It shows most of the techniques you need for a reliable LUT, even a simple bounds check with the "andlw 0x3f". (the table is 64 entries long)
To clarify, you can place this code in any bank and call it from any other bank using "call kblut". The call instruction pushes the full program counter on the stack, not just the low 8 bits, so the page you were in gets remembered. The "retlw" instruction in the table will send you back to the one after the "call".
This one doesn't take account of page boundaries within the table itself. So it's limited to about 250 entries, assuming you position it at the beginning of a page with the org directive. Microchip have an app note somewhere that shows how to do longer ones.
Registered Member #3546
Joined: Tue Dec 28 2010, 08:24AM
Location: Pittsburgh, PA
Posts: 18
I didn't realize that you could simply add org statements into the code like that, or at least I have never seen that done before? I figured it had something to do with the PCLATH register too but I just wasn't sure how to use it. Thank you for that example McConner.
This site is powered by e107, which is released under the GNU GPL License. All work on this site, except where otherwise noted, is licensed under a Creative Commons Attribution-ShareAlike 2.5 License. By submitting any information to this site, you agree that anything submitted will be so licensed. Please read our Disclaimer and Policies page for information on your rights and responsibilities regarding this site.