Managing I\O's
ThePenguinMaster
Posts: 89
hey guys,
·· hey this might be a simple question to some, but i need a little help managing my ins and outs.. im connecting the prop to a hard drive and all is well, but im unsure of how toget and set all the data properly. now i know thewres a better way to do it then typoing in all the pin numbers everytime, and i know i can declare and set a variable and then call ina[noparse][[/noparse]x], but im looking at some other chips and the language and im a little confused as to how they do it.
it looks like i should be able to do this:
con
·LowByte = $FF·········'ports 0-7
·HighByte = $FF0000· 'ports 16-23
·DataCommand = $EC
then i should be able to set the command to thease pins without effecting 8-15 or any of the others right? also i need to read from a specific range of pins... id rather not do the whole "ina[noparse][[/noparse]0..7]"
so for input can·i just say:
x:=ina[noparse][[/noparse]highbus]
or will that not work? any help would be mutch appreciated!
·
·· hey this might be a simple question to some, but i need a little help managing my ins and outs.. im connecting the prop to a hard drive and all is well, but im unsure of how toget and set all the data properly. now i know thewres a better way to do it then typoing in all the pin numbers everytime, and i know i can declare and set a variable and then call ina[noparse][[/noparse]x], but im looking at some other chips and the language and im a little confused as to how they do it.
it looks like i should be able to do this:
con
·LowByte = $FF·········'ports 0-7
·HighByte = $FF0000· 'ports 16-23
·DataCommand = $EC
then i should be able to set the command to thease pins without effecting 8-15 or any of the others right? also i need to read from a specific range of pins... id rather not do the whole "ina[noparse][[/noparse]0..7]"
so for input can·i just say:
x:=ina[noparse][[/noparse]highbus]
or will that not work? any help would be mutch appreciated!
·
Comments
"x := ina[noparse][[/noparse] 0..7 ]" and I/O pin 7 will be the least significant bit. You can do this for any sequential block of pins. It also works for outa and dira like
"outa[noparse][[/noparse] 7..0 ] := x". You can use constant names for the bit numbers for clarity, but there's no way to name a group of I/O pins. You could use the whole ina register and a named mask like
"x := ina & LowByte" and you can combine these terms like in
"x := ((ina & HighByte) >> 8) | (ina & LowByte)".
Post Edited (Mike Green) : 6/16/2007 2:52:07 PM GMT
after this section:
con
LowByte = $FF 'ports 0-7
HighByte = $FF0000 'ports 16-23
DataCommand = $EC
could i call a line like this or something like it? i know there was an sta() function or something they could use to acess the port a register directly maybe i could use that.. but heres what im trying to do.. or well, something like it..
outa[noparse][[/noparse]highbyte]:=datacommand
highbyte are pins 16-23 and i dont want to effect the lower pins, or higher pins while doing this transaction..
or you can do: outa[noparse][[/noparse] 23..16 ] := datacommand
The latter assumes that I/O pin 16 is the least significant bit.
well say pins 0-7
pins 0 - 3 are inputs, pins 4-7 are outputs,
using a mask of 11110000 will not effect the pins 0-3? (basically outputting to the 4 pins)
i know this may seem rather simple, i just dont want to wright a whole program relying on a concept that i may not fully understand. id do some experiments with my chip, but i dont want to pull it out of the project for that just yet.
Complicating this is the fact that INA always represents the state of the I/O pins no matter what is in the OUTA or DIRA registers. When you set INA to some value, you are not affecting the input register. You're changing a "shadow register". This is part of the reason why you can't use INA as a destination address for an instruction. In that case, you're actually referencing the "shadow register" which does exist in the hardware and can be used in this way if you're desperate for an extra memory location in the cog.
If the corresponding DIRA bit is a zero (indicating an input I/O pin), the state of the OUTA bit doesn't matter to the I/O circuitry.
Does this help?