You need to read the entire BYTE into the Stamp, using SHIFTIN. Then you can modify just the top bit using the AND operator with a mask of $7F which will set the top bit off. Then re-write the BYTE using SHIFTOUT.
You need to take what you got with the read, AND it with $7f and then send it back the first byte would be %10011010 ($1a with the MSB set to 1) the second byte would be the result of the previous read anded with $7f.
set_LASER_CTRLO = LASER_CTRLO & MASK 'value from read and MSB set to 1)
If you are trying to set the high bit on, you want to do this:
set_LASER_CTRLO = LASER_CTRLO | $80 'value from read and MSB set to 1)
To set a bit OFF you use AND (&) with a mask that specifies everything BUT the bit(s) to be turned OFF. To set a bit ON you use OR (|) with a mask that specifies the bit(s) to be turned ON.
Comments
You need to read the entire BYTE into the Stamp, using SHIFTIN. Then you can modify just the top bit using the AND operator with a mask of $7F which will set the top bit off. Then re-write the BYTE using SHIFTOUT.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
The following code is from your program:
set_LASER_CTRLO = LASER_CTRLO & MASK 'value from read and MSB set to 1)
If you are trying to set the high bit on, you want to do this:
set_LASER_CTRLO = LASER_CTRLO | $80 'value from read and MSB set to 1)
To set a bit OFF you use AND (&) with a mask that specifies everything BUT the bit(s) to be turned OFF. To set a bit ON you use OR (|) with a mask that specifies the bit(s) to be turned ON.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔