Help with project. How to input IR into HCS12

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help with project. How to input IR into HCS12

1,539 Views
demens
Contributor I
Hello guys,

I've been working on a project involving a 16 bit hcs12 family chip. I'm still at the early stages and i'm already having problems. The goal of the project is to use a signal from a tv remote to control a PC.

Well, i cant even figure out a way to input the IR signal from the remote into the chip. I initially wanted to make my own circuit, but now i'm using the Dragon12 evaluation board. the remote transmits a serial signal, so i tried using the SCI on the chip. I tried using an external IR receiver and the one on the board. it didnt work. I think the problem is that its made to accept 8 or 9 bits of data plus start, stop bit, but the remote outsputs much more. Not exactly sure how many cause i cant find any specs for it, i think its 12.

does anyone have any ideas or experience doing something like this? my next idea is to try and use an external 16-bit shift register and input that input port A and port B. i'm attaching a code i used to test the signal  using the SCI.

#include "c:\egnu110\include\hcs12.h"
#include "c:\egnu110\include\stdio.c"
#include "c:\egnu110\include\vectors12.h"
#define INTERRUPT __attribute__((interrupt))

void INTERRUPT SCI1_ISR (void);  //SCI1_ISR is a name i made up. not sure
                                 //if i can do that. the examples of other
                                 //interrupts had names like irq_isr, tov_isr,
                                 //tco_isr, paov_isr, etc. i didnt see these
                                 //names in the vertors file, or the hcs12 file
                                 //so i assume you can use any name....
void SCI_initialize ();

unsigned char datalow[20]; //stores 20 bytes of data
unsigned char datahigh[20];
const char *msg = "data read\r";
const char *msg1 = "idle detected\r";
const char *msg2 = "overflow\r";
const char *msg3 = "frame error\r";
int i;

int main (void)
{
    SCI_initialize ();
    asm("cli");
    while(1);    //wait for interrupt
    return 0;
}

void SCI_initialize ()
{
    UserSCI1 = (unsigned short)&SCI1_ISR;  //used same name as in prototype
    SCI1CR1=0x10;    //9-bit (0x00 for 8-bit), Idle wake (dontcare)
    SCI1CR2=0x34;    //RDRF & IDLE interrupts enabled 0011
                     //TE dis; RE en; Wake-up dis 0100
    SCI1BDH=0x00;    //Select 9600 Baud or dec=163(25mhz)
    SCI1BDL=0x9C;    //0x04 0xE2 for 1200 or dec=1302 (25mhz)
}

void INTERRUPT SCI1_ISR(void)  //again, same name as prototype
{

    //while(!(SCI1SR1 & RDRF));
    //while(SCI1SR1_RDRF == 0);

    if (SCI1SR1 & 0x20)     //is RDRF set?
        puts (msg);
    if (SCI1SR1 & 0x10)     //is IDLE set?
        puts (msg1);
    if (SCI1SR1 & 0x08)     //is OR set?
        puts (msg2);
    if (SCI1SR1 & 0x02)     //is FE set?
        puts (msg3);
       
    puts (datahigh[i]);    //print data & clear flags
    puts (datalow[i]);
    return;
}
Labels (1)
0 Kudos
1 Reply

349 Views
JimDon
Senior Contributor III
The signal from a remote is a gated 38kHz signal. The dragon has a 38Khz demodulator on it then feeds to the serail port, however each remote uses a different sort of protocol, and it is unlikly you will get the irda decoder to work with your remote, since they don't use irda.

What I would do is to connect the ouput of the 38Khz demodulator to an input bit that can interrupt on both edges, then have a counter so can count the high an low periods of the signal.
I would also look at this on a scope do get an idea of what th signal looks like.

Philips RC5 is a common format. Look here to get an idea of how your controller might encode data (I say might, because although RC5 is common, not all remotes use it). There are other protocol there as well which yours may follow.

Really what works best to creat a learn mode, so you can push a button an record the data from that key.



Message Edited by JimDon on 2008-04-27 09:15 PM
0 Kudos