bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

What went wrong?


From: Po Go
Subject: What went wrong?
Date: Sat, 13 Jun 2009 22:43:48 +0530

Dear sir/madam,
I am making an ir reciever which can read ir codes from a sony RM-W104 remote. The following programme on burning into my atmega8 didn't work.
#include <avr\io.h>
#include <avr\interrupt.h>
#include <avr\iom8.h>
#define ICP PINB0
int decode();
int byte;
//define times for start and end of signal
uint16_t rising, falling;
//define overall counts
uint32_t counts;
//Timer1 capture interrupt service subroutine
ISR(TIMER1_CAPT_vect)
{
/*This subroutine checks was it start of pulse (rising edge)
or was it end (fallingedge)and performs required operations*/
if(PINB0==0) //if low level
{
//save start time
falling=ICR1;
//set to trigger on rising edge
TCCR1B=TCCR1B&0x40;
}
else
{
//save rising time
rising=ICR1;
//falling edge triggers next
TCCR1B=TCCR1B|0xBF;
}
counts=(uint32_t)falling-(uint32_t)rising;
if(counts>=1200)
byte=1;
if(counts<1200)
byte=0;
/*you can convert coutns to seconds and send to LCD*/
}
int main(void)
{
int p1[8],p[8];
for(int j=0;j<8;j++)
{
p[j]=decode();
}
for(int u=0;u<8;u++)
{
p1[u]=decode();
}
if(p==p1)
{
DDRC=1;
PORTC=00000001;
}
return 0;
}
int decode()
{
int a[8];
//enable input capture interrupts
TIMSK=0x24;
/*Noise canceller, without prescaler, rising edge*/
TCCR1B=0xC1;
sei();
for (int i=0;i<8;i++)
{
a[i]=byte;
}
return a[8];
}

   

reply via email to

[Prev in Thread] Current Thread [Next in Thread]