Hi john,
I am using the same IR Receiver came with Value SB. The Receiver is able to receive the signals sent by Remote and I am able to view them on CRO. I have replaced these commands in the program code also. Still it is not responding to the remote. The remote is also 38kHz one.
The code is given below:
IR.C:
typedef struct
{
unsigned char nAddress;
unsigned char nCommand;
} TIR;
TIR ReadIR_RC5(void) //returns address and command
{
unsigned int n;
unsigned int nBit;
unsigned int pBits[RC5_BITS];
TIR rc5Data;
rc5Data.nAddress = 0;
rc5Data.nCommand = 0;
for (nBit = 0; nBit < RC5_BITS; nBit++)
{
pBits[nBit] = (~P1IN_bit.P1IN_2) & 0x01;
for (n = 0; n < 2762; n++);
}
rc5Data.nAddress = 0;
for (nBit = 0; nBit < 5; nBit++)
rc5Data.nAddress |= pBits[7 - nBit] << nBit;
rc5Data.nCommand = 0;
for (nBit = 0; nBit < 6; nBit++)
rc5Data.nCommand |= pBits[13 - nBit] << nBit;
return rc5Data;
}
void DispatchIR_RC5(TIR rc5Data)
{
if (!rc5Data.nAddress && !rc5Data.nCommand) return;
if (rc5Data.nAddress != RC5_ADDRESS) return;
switch (rc5Data.nCommand)
{
case RC5_CMD_VOL_UP:
Buttons(volumeUp);
break;
case RC5_CMD_VOL_DN:
Buttons(volumeDown);
break;
case RC5_CMD_MUTE:
Buttons(muteMode);
Delay_ms(1000);
break;
default:;
}
}
void ProcessIR(void)
{
// TIR necData = ReadIR_NEC();
// DispatchIR_NEC(necData);
TIR irData = ReadIR_RC5();
DispatchIR_RC5(irData);
}
IR.h:
#ifndef __IR_H
#define __IR_H
#define RC5_BITS 14
#define RC5_ADDRESS 0x00
#define RC5_CMD_VOL_UP 0x01
#define RC5_CMD_VOL_DN 0x02
#define RC5_CMD_MUTE 0x03
void ProcessIR(void);
#endif
Please check the code and kindly tell me where it is going wrong.
Regards,
Srinvas. T