PROGRAMING WITHOUT THE PAMUX DRIVER
Pamux User’s Guide
4-17
CombineUpperAndLowerBytes
This function takes two bytes and combines them into a 16-bit integer. QBasic requires an “if”
condition to prevent an overflow exception. This is used to read and combine two eight-bit port
values into one 16-bit integer such as when reading analog inputs.
FUNCTION CombineUpperAndLowerBytes% (UpperByte%, LowerByte%)
DIM Temp%
IF UpperByte% AND &H80 THEN
‘ Prevent overflow if negative
Temp% = ((UpperByte% AND &H7F) * &H100) OR &H8000
ELSE
Temp% = UpperByte% * &H100
‘ Shift left 8 bits
END IF
CombineUpperAndLowerBytes% = Temp% OR LowerByte%
END FUNCTION
GetUpperAndLowerBytes
This function takes a 16-bit integer and breaks it into two separate bytes. This is used to write analog
outputs, write 16 digital outputs (two banks), write watchdog values, and write watchdog times.
SUB GetUpperAndLowerBytes (Combined%, Upper%, Lower%)
Upper% = Combined% \ &H100
‘ Shift right 8 bits
Lower% = Combined% AND &HFF
END SUB
Содержание PAMUX
Страница 10: ...TABLE OF CONTENTS x Pamux User s Guide...
Страница 14: ...TABLE OF CONTENTS xiv Pamux User s Guide...
Страница 103: ...PROGRAMING WITH THE PAMUX DRIVER 3 42 Pamux User s Guide...
Страница 121: ...PROGRAMING WITHOUT THE PAMUX DRIVER 4 18 Pamux User s Guide...
Страница 125: ...TROUBLESHOOTING AND TIPS A 4 A 4 A 4 A 4 A 4 Pamux User s Guide...
Страница 135: ...SPECIFICATIONS B 10 Pamux User s Guide...
Страница 141: ...TEMPERATURE CONVERSIONS ROUTINES C 6 Pamux User s Guide...
Страница 143: ...PRODUCT SUPPORT D 2 Pamux User s Guide...
Страница 149: ...GLOSSARY E 6 Pamux User s Guide...