My Program would store the IR signal as ‘0’ or ‘1’ to the xdata 1kByte SRAM of DS89C450 and then display it on my MTK.
However, the data displayed only display character ‘F’ no matter what button i pressed on the IR remote control.(I have a CASE function that converts data into ASCII code, for this case ‘F’ = 0x0F).
http://img193.imageshack.us/img193/1410/66647882.png
Firstly: When IR Signal is received, the falling edge interrupt will trigger and store what every data is from the pin to x[i] every 38 us and Data_Ready is set to 1.
/******************************FALLING EDGE INTERRUPT*************************/
void ex_int0(void)interrupt 0
{
unsigned char p;
unsigned int u;
unsigned int i;
EA=0;
for(i=0;i<500;i++) //Loop for 500 bytes
{
for(u=0;u<8;u++) //Bit Shift Loop
{
timer0(); //Call timer0 function(38us)
x[i] = x[i] << 1; //Left Bit Shift by 1
p = Tsignal; //Store Tsignal to Buffer p
x[i] |= p; //OR Masking of p with x[i]
}
}
EA=1;
IE1 = 0;
Data_Ready = 1; //Set Data_Ready = 1
}//end
Next, The store data will be convert to ASCII code byte by byte. (eg. 1111 1111 = FF)
/******************************DISPLAY_BYTE***********************************/
void Display_Byte()
{
unsigned char Data_LK;
unsigned char MSB;
unsigned char LSB;
unsigned int v;
TR1=1; //Enable Serial Port
for(v=0;v<500;v++)
{
Data_LK = x[v]; //Store x[v] in Data_LK
MSB = Data_LK >> 4; //Shift Right Bits by 4
MSB &= 0x0F; //Mask bits of MSB
MSB = lookuptable(MSB); //Send MSB to lookuptable function
SerialTx(MSB); //Send Converted Data to transmit
LSB = x[v]; //Store x[v] in LSB
LSB &= 0x0F; //Mask bits of LSB
LSB = lookuptable(LSB); //Send LSB to lookuptable
SerialTx(LSB); //Send converted data to transmit
}
Data_Ready = 0; //Set Data_Ready to 0
TR1 = 0; //Turn off Serial Port
}
This is the lookuptable:
/***********************LOOKUP TABLE*************************************/
unsigned char lookuptable(unsigned char t)
{
switch(t)
{
case 0x00 : return '0';
break;
case 0x01 : return '1';
break;
case 0x02 : return '2';
break;
case 0x03 : return '3';
break;
case 0x04 : return '4';
break;
case 0x05 : return '5';
break;
case 0x06 : return '6';
break;
case 0x07 : return '7';
break;
case 0x08 : return '8';
break;
case 0x09 : return '9';
break;
case 0x0A : return 'A';
break;
case 0x0B : return 'B';
break;
case 0x0C : return 'C';
break;
case 0x0D : return 'D';
break;
case 0x0E : return 'E';
break;
case 0x0F : return 'F';
break;
default: break;
}// end switch
}// end function
At least one of the errors is that you are not doing anything with the result of the calls to lookuptable() so you are transmitting the unconverted MSB and LSB values.
You probably meant to do something like this: