gramo New Member Oct 5, 2006 #1 Just trying to figure out the equivilent for Proton+ picbasic, PICBASIC Pro bit setting/clearing with a variable: porta.0[Variable] = 1 'sets bit(variable) of porta porta.0[Variable] = 0 'clears bit(variable) of porta Proton+ : doesn’t work.. it can only modify register bits with addressing of constants in that manner. If someone knows how to over come this - please let me know
Just trying to figure out the equivilent for Proton+ picbasic, PICBASIC Pro bit setting/clearing with a variable: porta.0[Variable] = 1 'sets bit(variable) of porta porta.0[Variable] = 0 'clears bit(variable) of porta Proton+ : doesn’t work.. it can only modify register bits with addressing of constants in that manner. If someone knows how to over come this - please let me know
P Pommie Well-Known Member Most Helpful Member Oct 5, 2006 #2 I'm not familiar with that version of basic. A generic way to do this would be, PORTA = PORTA OR (1 << Variable) To set the bit and PORTA = PORTA AND (255 - (1 << Variable)) To clear the bit. The << operation is shift left. Variable would contain 0 to 7. Mike.
I'm not familiar with that version of basic. A generic way to do this would be, PORTA = PORTA OR (1 << Variable) To set the bit and PORTA = PORTA AND (255 - (1 << Variable)) To clear the bit. The << operation is shift left. Variable would contain 0 to 7. Mike.
gramo New Member Oct 5, 2006 #3 someone on sparky hit the nail on the head for the proton+ equivilent: Dim INDEX As Byte For INDEX = 0 to 7 If GetBit PORTA,INDEX = 1 Then ' do something interesting EndIf Next and to clear bits indexed via variables: CLEARBIT Variable , Index
someone on sparky hit the nail on the head for the proton+ equivilent: Dim INDEX As Byte For INDEX = 0 to 7 If GetBit PORTA,INDEX = 1 Then ' do something interesting EndIf Next and to clear bits indexed via variables: CLEARBIT Variable , Index