Can someone teach me the OUTS of DIRS?
firestorm.v1
Posts: 94
Ok, so after many moons of not having enough time, I finally dusted off my BS2 and started working with it.
I have an HD44780 LCD and am using Parallax's code to run my LCD (see prod #603-00006)
I an initially trying to get the thing working for now, but eventually will be switching to 8bit mode as I have more pins than I need and I just got done building an 14 pin single inline pin header cable for working with the LCD.
The issue I'm having is that I can't remember for the life of me if OUTS and DIRS are LSB-MSB or backwards, i.e. if I want pins 1-8 and 9,10,11 to be outs and the rest input: (say I'm sending 255 through an OUTS statement)
Is it like this:
DIRS=%1111111111100000
OUTS=%1111111100000000
or like this:
DIRS=%0000011111111111
OUTS=%0000000011111111
My LCD is hooked up as follows:
Pin 0-7 -> D0-7 on the LCD
Pin 8 -> E
Pin 9 -> RW
Pin 10 -> RS
Will setting DIRs affect me being able to manually set the pin state of E,RW,RS (or pin 16 later on for a ping sensor?)
Thanks for your time!
I have an HD44780 LCD and am using Parallax's code to run my LCD (see prod #603-00006)
I an initially trying to get the thing working for now, but eventually will be switching to 8bit mode as I have more pins than I need and I just got done building an 14 pin single inline pin header cable for working with the LCD.
The issue I'm having is that I can't remember for the life of me if OUTS and DIRS are LSB-MSB or backwards, i.e. if I want pins 1-8 and 9,10,11 to be outs and the rest input: (say I'm sending 255 through an OUTS statement)
Is it like this:
DIRS=%1111111111100000
OUTS=%1111111100000000
or like this:
DIRS=%0000011111111111
OUTS=%0000000011111111
My LCD is hooked up as follows:
Pin 0-7 -> D0-7 on the LCD
Pin 8 -> E
Pin 9 -> RW
Pin 10 -> RS
Will setting DIRs affect me being able to manually set the pin state of E,RW,RS (or pin 16 later on for a ping sensor?)
Thanks for your time!
Comments
When you set DIRS (or any piece of it like DIRA or DIRL), you're just setting it at that very moment. If you use a statement (like HIGH / LOW / INPUT) that changes the mode of a specific I/O pin, that actually changes the specific bit in DIRS.
Anytime I use the % symbol on OUTS, this means that the rightmost bit will always be pin 0, correct?
e.g. OUTS=%10000 and OUTS =%10 don't matter in respect to pin 0, but the first example sends pin4 high while the second one sends pin 1 high.
and with that said, if I don't use the binary operator % if I OUTS a number less than 255, I shouldn't have an issue colliding with the control pins for the LCD?
Thank you for clarifying it, I just want to make sure I'm seeing it correctly. [noparse]:)[/noparse]
and then you go and do: OUTS = %01
you do not end up with the OUTS register = %1111111100000001
what you get is the OUTS register = %0000000000000001
You can always refer to the documentation available through the help menu of Parallax's BASIC Stamp IDE.
I think I have managed to confuse myself and in the process have confused all of you.
I know how binary works and I did check the parallax documentation in the IDE however it was as clear as mud. (Seriously, search DIRS and tell me if there is anything that directly states whether or not DIRS is lsb-msb or msb-lsb?)
The question is:
If I send OUTS=%0011, this should set pins 0,1 as high and if I set OUTS as %1100, this should set pins 0 and 1 as low, 2 and 3 as high. If I OUTS, say 255, then pins 0-7 will be high, with the rest low, correct?
Thank you all for your assistance.
Edit:
Another question which may be causing the confusion. If I set DIRS=%111000111 (should be pins 3-5 as outputs) and I OUTS=%1111 Does this mean that the pin states will be pins 0-3 high?
Post Edited (firestorm.v1) : 12/15/2009 11:31:10 AM GMT
25 is the same as 000000025·or 025 or 0000000000000000000025.
Post Edited (PJ Allen) : 12/15/2009 12:16:39 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Check out the new Savage Circuits TV!
·