Writing to a register
firewater
Posts: 25
I
Post Edited (firewater) : 7/19/2008 6:10:37 PM GMT
Post Edited (firewater) : 7/19/2008 6:10:37 PM GMT
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔