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 #49
Joined: Thu Feb 09 2006, 04:05AM
Location: Bigass Pile of Penguins
Posts: 362
Easy question, just dont have a PIC on hand to lash up and resolve this for myself:
When I move binary bytes to the PIC ports, which port bit corresponds to which bit in my binary string. For example, does 00000001 have the "1" in the pin 0 or pin 7 position??
Is this true for bank 0 and bank 1?
I ask because I *think* i remember setting the port directions in bank 1 operating differently that setting the output states normally in bank 0
Registered Member #27
Joined: Fri Feb 03 2006, 02:20AM
Location: Hyperborea
Posts: 2058
RA0 and RB0 both corresponds to bit 0 in the file registers, so they are identical in that sense and there are no differences in how they are set up.
Port B has programmable pull up resistors for input. Port A may have only 5 I/O lines, depending on the model. Port A may have a pin with open collector and may require an external pull-up resistor or a diode to protect it from overvoltage.
Registered Member #65
Joined: Thu Feb 09 2006, 06:43AM
Location:
Posts: 1155
1.) Multibyte variables are generally “Little Endian†these days (unless one runs a SPARC machine etc. which is “Big Endian†.) ( ) It refers to how multi-byte variables like “unsigned int†are ordered when stored in memory. If ones defined a union or struct this can be a source of confusion and porting bugs. Also, if one declares signed integer math then “overflow reset†monitoring may make the code far more complex than needed.
2.) Simply put, the Microchip standard states RA0 as being the Least Significant Bit ( ) of a memory address often referring to a single byte’s bit on the right side. As Little-Endian reorders byte sequences it is a common source of bugs when doing direct bit wise operations with i/o and relying on the compiler to correctly downcast the variable. To keep it simple Microchip avoids these problems by forcing the programmer to downcast the output to 1 byte (unsigned char). RA0 := ‘00000001’b RA1 := ‘00000010’b Etc.
3.) Most C compilers implement a C standard procedure stack order. When translated into procedure calls it is standard to pass arguments from right to left on the stack. When using precompiled libraries and extern calls to binary objects this can be an issue. This is why Pascal object code integration is rather rare as arguments would pass left to right on the stack in the compiler making it incompatible (only mentioned as there are numerous compilers for PICs out there that implement non-standard linker systems.)
4.) Microchips “Read Modify Write†bug is a problem that has documented procedures to avoid. See the app notes.
5.) Also the rotate ASM calls will sometimes carry in garbage from the flags if one forgets to backup, clean, and restore the core state to perform operations with interrupts active.
6.) 'xxxxxx1x'h != 'xxxxxx1x'b is a common typo
7.) Not all memory addresses are mirrored between ram banks (see TRISA and PORTA defines in the compilers pic16xxx.inc etc.)
This should cover most of the common bit related bugs, Good luck,
Registered Member #27
Joined: Fri Feb 03 2006, 02:20AM
Location: Hyperborea
Posts: 2058
If the question is about the I/O ports after all, then it is the opposite. When looking at the row of pins that is closes to you then bit 0 is to the left on chips like the 16F84 and 16F870. If you don't rotate the chip when you work on the other side then the ports on the other side will be mirrored since it is upside down.
The rule is that the significance of the bits follow the numbering of the pins so the least significant bits always have the lowest pin numbers.
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.