If you are using this famous protocol (RC5, as was developed by Philips) for several IR based remote control applications, then you may utilize this part of the code of mine to embed in your existing system and save your development time. This part of the code is COMPLETELY FREE and may be used, reused or distributed at the user’s will.
WHAT IS THIS RC5 PROTOCOL ?
(as the Wikipedia says) The RC-5 protocol was developed by Philips in the late 1980s as a semi proprietary consumer IR (infrared) remote control communication protocol for consumer electronics. However it was also adopted by most European manufacturers, as well as many US manufacturers of specialty audio and video equipment. The other main protocol used by consumer electronics manufacturers is the NEC protocol. This protocol is largely used by Japanese manufacturers and assigns each brand with its own unique header(s). Each brand is then free to create any command set it wishes. The advantage of the NEC protocol is that there cannot be any interference between remote handsets for pieces of equipment made by different manufacturers. The advantage of the RC-5 protocol is that (when properly followed) any CD handset (for example) may be used to control any brand of CD player using the RC-5 protocol.
Protocol Details:
The basics of the protocol are well known. The handset contains a keypad and a transmitter integrated circuit (IC) driving an IR LED.[1] The command data is a Manchester coded bit stream modulating a 36 kHz carrier. (Often the carrier used is 38 kHz or 40 kHz, apparently due to misinformation about the actual protocol.) The IR signal from the transmitter is detected by a specialized IC with an integral photo-diode, and is amplified, filtered, and demodulated so that the receiving device can act upon the received command.[2] RC-5 only provides a one-way link, with information traveling from the handset to the receiving unit.
The command comprises 14 bits:
- A start bit, which is always logic 1 and allows the receiving IC to set the proper gain.
- A field bit, which denotes whether the command sent is in the lower field (logic 1 = 0 to 63 decimal) or the upper field (logic 0 = 64 to 127 decimal). Originally a second start bit, the field bit was added later by Philips when it was realized that 64 commands per device were insufficient. Many devices still use the original system.
- A control bit, which toggles with each button press. This allows the receiving device to distinguish between two successive button presses (such as “1”, “1” for “11”) as opposed to the user simply holding down the button and the repeating commands being interrupted by a person walking by, for example.
- A five-bit system address, that selects one of 32 possible systems.
- A six-bit command, that (in conjunction with the field bit) represents one of the 128 possible RC-5 commands.
The 36 kHz carrier frequency was chosen to render the system immune to interference from TV scan lines. Since the repetition of the 36 kHz carrier is 27.778 μs and the duty factor is 25%, the carrier pulse duration is 6.944 μs. Each bit of the RC-5 code word contains 32 carrier pulses, and an equal duration of silence, so the bit time is 64×27.778 μs = 1.778 ms, and the 14 symbols (bits) of a complete RC-5 code word take 24.889 ms to transmit. The code word is repeated every 113.778 ms (4096 / 36 kHz) as long as a key remains pressed. (Again, please note that these timings are not strictly followed by all manufacturers, due to a lack of widespread distribution of accurate information on the RC-5 protocol.)
For more details, see the Wiki page here directly.
To download the complete CCS project for decoding this protocol for address and data, click here. This code was tested at my lab. I could not upload the test schematics and the DSO screenshots, however, I shall be doing so very soon. In the meantime, you can read the port definitions and make a presumption where the IR sensor is connected. It uses the CCP module.
I suggest you to please go through the datasheet of TM4C123GH6PM before proceeding with this archive. Please use CCS v6.x
FOR ANY QUERIES FEEL FREE TO COMMENT BELOW, I WILL ANSWER ASAP!
IF YOU LIKE IT, SHARE IT SOCIALLY PLEASE.