Decode RC5 ?


Closed Thread
Results 1 to 8 of 8

Thread: Decode RC5 ?

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default RC5

    Here's a section of a routine I've use to decode RC5. It's pretty simple.

    '// Philips RC5 IR decoder

    DEFINE OSC 20
    DEFINE LOADER_USED 1
    DEFINE HSER_BAUD 2400

    Y VAR WORD ' Holds 12-bit RC5 code
    Loop VAR BYTE ' Loop variable
    PIN VAR PORTB.0 ' RB.0 input pin reading data

    TRISB.0=1 ' Set RB.0 direction to input
    OPTION_REG.7 = 0 ' Internal pull-ups = on

    Home:
    IF PIN = 1 THEN Home ' Wait for low going pulse
    PAUSEUS 100 ' Short delay
    IF PIN = 1 THEN Home ' Was it noise?
    PAUSEUS 1350 ' Pause to read 2nd half of 1st bit period

    Y.0[13] = PIN ' Record 1st synch period bit value
    FOR Loop = 12 to 0 STEP - 1 ' 13 pulses MSB to LSB
    Y.0[Loop] = PIN ' Y.Bit.Loop = data bit
    PAUSEUS 1800 ' Wait 1.8mS to read next RC5 bit
    NEXT Loop ' in middle of 2nd bit period

    IF Y.LowByte = $FF THEN Home ' Was it noise?
    Y = ~Y & $003F ' Mask upper 10-bits to return 6-bit data
    ' in lower 6-bits of word result
    HSEROUT ["Key Pressed = ",DEC Y,13,10]
    Y=0 ' Clear key codes
    PAUSE 250 ' Used for testing only
    GOTO Home ' Return Home

    Here's a tutorial on the RC5 protocol that will give you a better understanding of how & why the above code works.

    http://www.xs4all.nl/~sbp/knowledge/ir/rc5.htm
    Last edited by Bruce; - 4th April 2004 at 05:06.
    Regards,

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

Similar Threads

  1. RC5 code for infrared receiver
    By Dennis in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 11th January 2017, 12:34
  2. Timer + rc5
    By naga in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 19th November 2009, 07:56
  3. RC5 decode on a 10F + Question
    By ultiblade in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 11th September 2008, 08:20
  4. IR decode problem "hitachi TV remote"
    By chai98a in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th March 2006, 15:29
  5. RC5 Encode / Decode
    By charudatt in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 18th October 2003, 05:14

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