Shop OBEX P1 Docs P2 Docs Learn Events
Extracting data from variables — Parallax Forums

Extracting data from variables

ArchiverArchiver Posts: 46,084
edited 2001-02-05 15:38 in General Discussion
Hi all,

here's another stupid question for you.

I use a CDP68HC68P1 SPI interface 8bit I/O device which gives me 8 bi-
directional I/O lines. Using Shiftin I read the state of the I/O's
and store the info in a variable 'indata'. I can then read each bit
as shown below.

indata VAR byte
insensor VAR indata.bit0
ip13 VAR indata.bit1
ip14 VAR indata.bit2
minus VAR indata.bit3
plus VAR indata.bit4
loopsw1 VAR indata.bit5
loopsw2 VAR indata.bit6
limits VAR indata.bit7

GOSUB transfer_in
IF insensor=1 THEN see_form

transfer_in: ' GET I/P DATA FROM I/O CHIP
LOW CE ' enable chip
SHIFTOUT MOSI,SCK,1,[noparse][[/noparse]%00001001] ' send request data
' PAUSE 10
SHIFTIN MISO,SCK,1,[noparse][[/noparse]indata] ' receive data
HIGH CE ' disable chip
PULSOUT CE,10 ' pulse enable pin
RETURN ' return to original routine

Under normal working indata=00000000. My problem is if I have a '1'
in limits and then get a '1' on insensor, insensor does not read it.
What am I doing wrong?

Anybody got any ideas?

cheers

Jon
Sign In or Register to comment.