"NCD returns the priority encoded bit number (1 - 16) of a value. It is used to find the highest bit set in a value. It returns 0 if no bit is set.
B0 = NCD %01001000 ' Sets B0 to 7"
Uh... yes, fine, unless I need the LOWEST priority.
In fact, for the project, pins 0 to 4 are used to record an area hit on the player for a lasergame equipment. Area0 (A.0) is the head while A4 is the right arm...
So I would need to scan from pin0 to pin4 and process the signal as soon as I find a pin that is LOW (pins are default HIGH).
I might use REV first: (porta has only 6 pins on PIC16F690, so bits 6 and 7 should be 0... or not? Maybe I should make sure bits 6:7 are cleared before I do that)
reversed_a = a REV 8 'reverse 8 bits of variable a in which I mirrored PORTA register
triggered_pin = NCD reversed_a 'find the priority bit
I guess this should do the trick but will these two line be faster that my code in my previous post? I wonder.
Bookmarks