I've been playing around with some old programs trying to "make them better", otherwise interpreted as "it works so now I'll break it".
Thanks to some guidance from here, I'm now reasonably comfortable with writing to multiple pins in one command and, even better, understand why it is better than a string of multiple single pin writes.
But I'm stuck coming the other way![]()
-I can read PORTB in one go, easy.
-I can mask which pins I'm interested in, easy.
-But I can't figure out how to easily extract say bit 3 of my PORTB byte into a single bit variable. I can & it with a mask and set the bit depending on the results but it seems there must be a better way than this:
BUTTONS var BYTE
Menu_1 VAR bit
If (BUTTONS & %00001000) = 1 THEN Menu_1 = 1
If (BUTTONS & %00001000) = 0 THEN Menu_1 = 0
Any guidance welcome
Thanks, Andrew
Bookmarks