Bit stuffing problem!


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Try this;
    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
    This sets or clear bits 0-5 in Rx_Byte as indexed by w. No shifting required.

    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.
    Last edited by Bruce; - 1st November 2004 at 21:55.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  4. DMX512 Problem ..Schema+Code
    By programmer07 in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 21st March 2007, 15:39
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts