Convert WORD variable to 16 bit array?
Falcon
Posts: 191
Hello,
I'm using the "two 74HC165 Shift Register" circuit from Stampworks V 2.1 to save some input pins. See below:
'
[ I/O Definitions ]
Clock PIN 0 ' shift clock (74HC165.2)
SerData PIN 1 ' serial data (74HC165.7)
Load PIN 2 ' output latch (74HC165.1)
'
[ Constants ]
DelayTime CON 100
'
[ Variables ]
xInputs VAR Word ' external inputs
'
[ Initialization ]
Reset:
HIGH Load ' make output and high
DEBUG CLS,
"XInputs FEDCBA9876543210", CR,
"
", CR,
"Status ................"
'
[ Program Code ]
Main:
DO
GOSUB Get_165x2 ' get inputs
DEBUG CRSRXY, 10, 2, BIN16 xInputs ' display current status
PAUSE DelayTime ' pad the loop a bit
LOOP
'
[ Subroutines ]
Get_165x2:
PULSOUT Load, 5 ' load inputs
SHIFTIN SerData, Clock, MSBPRE, [xInputs\16] ' shift them in
RETURN
My code needs to have the 16 bits of data in the xInputs WORD variable converted into a 16 bit array so each bit can be individually compared to a previous state. How can the WORD variable be converted to a 16 bit array?
falcon
I'm using the "two 74HC165 Shift Register" circuit from Stampworks V 2.1 to save some input pins. See below:
'
[ I/O Definitions ]
Clock PIN 0 ' shift clock (74HC165.2)
SerData PIN 1 ' serial data (74HC165.7)
Load PIN 2 ' output latch (74HC165.1)
'
[ Constants ]
DelayTime CON 100
'
[ Variables ]
xInputs VAR Word ' external inputs
'
[ Initialization ]
Reset:
HIGH Load ' make output and high
DEBUG CLS,
"XInputs FEDCBA9876543210", CR,
"
", CR,
"Status ................"
'
[ Program Code ]
Main:
DO
GOSUB Get_165x2 ' get inputs
DEBUG CRSRXY, 10, 2, BIN16 xInputs ' display current status
PAUSE DelayTime ' pad the loop a bit
LOOP
'
[ Subroutines ]
Get_165x2:
PULSOUT Load, 5 ' load inputs
SHIFTIN SerData, Clock, MSBPRE, [xInputs\16] ' shift them in
RETURN
My code needs to have the 16 bits of data in the xInputs WORD variable converted into a 16 bit array so each bit can be individually compared to a previous state. How can the WORD variable be converted to a 16 bit array?
falcon
Comments
Using a certain bit...
Or using an indexed array...
But just to know for future reference, is there a way to take a Byte or WORD variable and convert it to an 8- or 16-bit array?
falcon