Try this;
This sets or clear bits 0-5 in Rx_Byte as indexed by w. No shifting required.Code:Start: Pulse = 0 PULSIN Rx_Pin, 0, Pulse IF Pulse < 290 THEN Start Get_Data: FOR i = 0 to 6 ' 7 bytes FOR w = 0 TO 5 ' 6 bits PULSIN Rx_Pin, 0, Pulse IF Pulse > 80 and Pulse < 120 THEN Rx_Byte.0[w] = 0 IF Pulse > 180 AND Pulse < 220 Then Rx_Byte.0[w] = 1 NEXT w Rx_Data[i] = Rx_Byte & %00111111 ' Mask upper 2-bits NEXT i i = 0 w = 0 GOSUB Send_Data GOTO Start
Rx_Byte.0[w] is the same as Rx_Byte.bit.w where w holds the bit index # to set or clear. I.E. from bits 0 to 5 in Rx_Byte.
Rx_Data[i] = Rx_Byte & %00111111 masks the upper two bits from Rx_Byte leaving these two bit positions clear.
If you need to work from bit 5 to bit 0, then change FOR w = 0 TO 5 to --> FOR w = 5 TO 0 STEP - 1.




Bookmarks