hi,
I am writing driver for Irda remote controler.
my bsp is samsung 2440.
irda sensor is connected to the gpio pin.
my problem is detecting the time between raise and fall of gpio pin. since
it is in micro seconds.

is there any method to do this accurately?.

regards

Himanth.

Re: Consumer IRDa Remote control by Henrik

Henrik
Thu Jan 05 05:45:17 CST 2006

Are you by any chanse meaning "IR remote controller" (not irda)?
Usually you do not connect IRDA hardware on any gpio pins -you connect
it to a UART designed for irda.

On the other hand, an IR remote sensor for recieving RC-5 codes or
similar (i. e. tv-remote), you would probably hook up to a gpio pin.
How short times are we talking about?

I've done a couple of remote control recievers, and I've allways been
able to hook up hw timers so that they are flank-trigged by the gpio.
Togehter with an interupt, it's trivial to retrieve the inter-flank
time. You could also get away with using a free running counter to
calculate the number of ticks between interrupts.

Henrik Viklund


Re: Consumer IRDa Remote control by himanth

himanth
Thu Jan 05 23:30:03 CST 2006

Dear Mr. Henrik Viklund
Thanks for your reply.
you r right i am using IR remote controller(like TV.remote).
i am developing mp3 player based on samsug2440.
i tryed method u mentioned.
my problem is when i use hw timer it detects only 18 bits.
my code works fine except when music is playing.
once the player started after remote is not functioning.
can u please send me sample code.
my mail id is himanthyes(@)hotmail.com.

snippet from my driver.

switch(dwEvent)
{
case WAIT_OBJECT_0:
if(IRStart == FALSE)
{
IRStart = TRUE;
}
else
{
IRStart = FALSE;
while(!((v_pIOPregs->rGPHDAT) & (1 << 7)))
{
// IRCount++;
}
while(((v_pIOPregs->rGPHDAT) & (1 << 7)))
{
IRCount++;
}
RETAILMSG(1,(TEXT("%d "),IRCount));
if(IRCount > 30000)
{
IRIndex =0;
for(Cnt =0; Cnt < 31; Cnt++) IRDataBuff[Cnt] =0;
RETAILMSG(1,(TEXT("\n")));
}
else if(IRCount > 10000)
{
IRDataBuff[IRIndex]= 1;IRIndex++;
}
else
{
IRDataBuff[IRIndex]= 0;IRIndex++;
}
if(IRIndex > 31)
{
Data =0;
for(Cnt = 0; Cnt < 8; Cnt++)
{
Data = Data << 1;
Data = Data | IRDataBuff[Cnt];
}
IRCustomData1 = Data;
RETAILMSG(1,(TEXT(" %d "),Data));
Data=0;
for(Cnt = 8; Cnt < 16; Cnt++)
{
Data = Data << 1;
Data = Data | IRDataBuff[Cnt];
}
IRCustomData2 = Data;
RETAILMSG(1,(TEXT(" %d "),Data));
Data=0;
for(Cnt = 16; Cnt <24; Cnt++)
{
Data = Data << 1;
Data = Data | IRDataBuff[Cnt];
}
IRData1 = Data;
RETAILMSG(1,(TEXT(" %d "),Data));
Data=0;
for(Cnt = 24; Cnt < 32; Cnt++)
{
Data = Data << 1;
Data = Data | IRDataBuff[Cnt];
}
IRData2 = Data;
RETAILMSG(1,(TEXT(" %d \n"),Data));

if((IRData1 + IRData2)==0xFF)
{
switch(IRData1)
{
case 0x81:
v_pDriverGlobals->baUDID[0] = KEY1;
RETAILMSG(1,(TEXT("F1 Key\n")));
break;
case 0x41:
v_pDriverGlobals->baUDID[0] = KEY2;
RETAILMSG(1,(TEXT("F2 Key\n")));
break;
case 0x61:
v_pDriverGlobals->baUDID[0] = KEY3;
RETAILMSG(1,(TEXT("F3 Key\n")));
break;
case 0x21:
v_pDriverGlobals->baUDID[0] = KEY4;
RETAILMSG(1,(TEXT("F4 Key\n")));
break;
}

}
}
IRCount =0;
}
InterruptDone(SYSINTR_IR);

break;
case WAIT_TIMEOUT:
IRIndex =0;
IRCount =0;
break;
}

warm regards

Himanth



Re: Consumer IRDa Remote control by Henrik

Henrik
Fri Jan 06 05:18:57 CST 2006

The code was written for another platform that had the capability to
hook up alternating counters to be trigged by gpio flanks, which
greatly simplified the algoritm, so it would be of marignal use for
you.

Anyway, if it works when you're not playing mp3, the extra cpu-load the
mp3 decoder is creating might cause your IST to miss its deadlines. If
you havn't allready, you could try raising the IST priority and see if
things stabilize.

Henrik Viklund

Himanth wrote:
> Dear Mr. Henrik Viklund
> Thanks for your reply.
> you r right i am using IR remote controller(like TV.remote).
> i am developing mp3 player based on samsug2440.
> i tryed method u mentioned.
> my problem is when i use hw timer it detects only 18 bits.
> my code works fine except when music is playing.
> once the player started after remote is not functioning.
> can u please send me sample code.
> my mail id is himanthyes(@)hotmail.com.
>
> snippet from my driver.
>
> switch(dwEvent)
> {
> case WAIT_OBJECT_0:
> if(IRStart == FALSE)
> {
> IRStart = TRUE;
> }
> else
> {
> IRStart = FALSE;
> while(!((v_pIOPregs->rGPHDAT) & (1 << 7)))
> {
> // IRCount++;
> }
> while(((v_pIOPregs->rGPHDAT) & (1 << 7)))
> {
> IRCount++;
> }
> RETAILMSG(1,(TEXT("%d "),IRCount));
> if(IRCount > 30000)
> {
> IRIndex =0;
> for(Cnt =0; Cnt < 31; Cnt++) IRDataBuff[Cnt] =0;
> RETAILMSG(1,(TEXT("\n")));
> }
> else if(IRCount > 10000)
> {
> IRDataBuff[IRIndex]= 1;IRIndex++;
> }
> else
> {
> IRDataBuff[IRIndex]= 0;IRIndex++;
> }
> if(IRIndex > 31)
> {
> Data =0;
> for(Cnt = 0; Cnt < 8; Cnt++)
> {
> Data = Data << 1;
> Data = Data | IRDataBuff[Cnt];
> }
> IRCustomData1 = Data;
> RETAILMSG(1,(TEXT(" %d "),Data));
> Data=0;
> for(Cnt = 8; Cnt < 16; Cnt++)
> {
> Data = Data << 1;
> Data = Data | IRDataBuff[Cnt];
> }
> IRCustomData2 = Data;
> RETAILMSG(1,(TEXT(" %d "),Data));
> Data=0;
> for(Cnt = 16; Cnt <24; Cnt++)
> {
> Data = Data << 1;
> Data = Data | IRDataBuff[Cnt];
> }
> IRData1 = Data;
> RETAILMSG(1,(TEXT(" %d "),Data));
> Data=0;
> for(Cnt = 24; Cnt < 32; Cnt++)
> {
> Data = Data << 1;
> Data = Data | IRDataBuff[Cnt];
> }
> IRData2 = Data;
> RETAILMSG(1,(TEXT(" %d \n"),Data));
>
> if((IRData1 + IRData2)==0xFF)
> {
> switch(IRData1)
> {
> case 0x81:
> v_pDriverGlobals->baUDID[0] = KEY1;
> RETAILMSG(1,(TEXT("F1 Key\n")));
> break;
> case 0x41:
> v_pDriverGlobals->baUDID[0] = KEY2;
> RETAILMSG(1,(TEXT("F2 Key\n")));
> break;
> case 0x61:
> v_pDriverGlobals->baUDID[0] = KEY3;
> RETAILMSG(1,(TEXT("F3 Key\n")));
> break;
> case 0x21:
> v_pDriverGlobals->baUDID[0] = KEY4;
> RETAILMSG(1,(TEXT("F4 Key\n")));
> break;
> }
>
> }
> }
> IRCount =0;
> }
> InterruptDone(SYSINTR_IR);
>
> break;
> case WAIT_TIMEOUT:
> IRIndex =0;
> IRCount =0;
> break;
> }
>
> warm regards
>
> Himanth