The INs and OUTs of DIRS.....
firestorm.v1
Posts: 94
Ok, tacky title joke aside....
I am having some problems with setting directions of some I/O pins for the purpose of reading/writing to a benchmarq real time clock chip.
There are three control pins, (RW,Address,Data) and 8 data pins.
http://www.chipcatalog.com/Datasheet/E9B216E64AB8C802E9CB0F3AE6D47A07.htm (this is the chip manual)
The CS is tied to Vss (ground) to keep the chip always enabled.
Here's the read code:
HIGH rw
HIGH address
DIRL=255
OUTL=address_to_read
DEBUG "Read address ",DEC2 ad," Get "
LOW address
DIRL=0
HIGH data_pin
GOSUB check_ports
LOW data_pin
The SUB "check_ports" is designed to read the 8 inputs (pin0-7).
What happens is that the chec ports routine reflects the last data lines sent to the chip, e.g. if I'm reading address 20 (b:10100), then 10100 is what I get back.
I though that setting DIRL=0 would set all lower 8 pins to incoming rather than outgoing, correct?
Am I strobing something wrong or am I thinking that DIRL resets the states of the 8 pins when following an OUTL command?
Thanks for everyone's help, I really appreciate it.
FIRESTORM_v1
I am having some problems with setting directions of some I/O pins for the purpose of reading/writing to a benchmarq real time clock chip.
There are three control pins, (RW,Address,Data) and 8 data pins.
http://www.chipcatalog.com/Datasheet/E9B216E64AB8C802E9CB0F3AE6D47A07.htm (this is the chip manual)
The CS is tied to Vss (ground) to keep the chip always enabled.
Here's the read code:
HIGH rw
HIGH address
DIRL=255
OUTL=address_to_read
DEBUG "Read address ",DEC2 ad," Get "
LOW address
DIRL=0
HIGH data_pin
GOSUB check_ports
LOW data_pin
The SUB "check_ports" is designed to read the 8 inputs (pin0-7).
What happens is that the chec ports routine reflects the last data lines sent to the chip, e.g. if I'm reading address 20 (b:10100), then 10100 is what I get back.
I though that setting DIRL=0 would set all lower 8 pins to incoming rather than outgoing, correct?
Am I strobing something wrong or am I thinking that DIRL resets the states of the 8 pins when following an OUTL command?
Thanks for everyone's help, I really appreciate it.
FIRESTORM_v1