Aayush Awasthi
Junior Member level 2
- Joined
- Nov 18, 2013
- Messages
- 20
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 128
there is a program of TSOP but an error has come that is ../newknp.c:119: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
and a warning c:/winavr-20080610/lib/gcc/../../avr/include/util/delay.h:85:3: warning: #warning "F_CPU not defined for <util/delay.h>"
pls give some help i want ....
and a warning c:/winavr-20080610/lib/gcc/../../avr/include/util/delay.h:85:3: warning: #warning "F_CPU not defined for <util/delay.h>"
pls give some help i want ....
Code:
#include<avr/io.h>
#include<util/delay.h>
//#include<avr/interrupt.h>
#include<stdio.h>
#define TIM1_CAPT 6
#define LCD_RS 0
#define LCD_RW 1
#define LCD_EN 2
#define LCD PORTC
#define F_CPU 1000000UL
void lcd_config();
void lcd_cmd(unsigned char);
void lcd_data(unsigned char);
int lcd_num(int);
// Timer 1 input capture interrupt service routine
interrupt [TIM1_CAPT] void timer1_capt_isr(void);
int main(void)
{
DDRC=0xFF;
DDRD=0x00;
//DDRB=0xFF;
/* sei();
MCUCR=0b00000010;
GICR=0b010000000;
lcd_config();
*/ while(1)
{
}
}
/*
ISR(INT0_vect)
{
int x;
PORTB=0xFF;
lcd_config();
lcd_cmd(0x01);
_delay_ms(100);
lcd_cmd(0x80);
x=PIND;
lcd_num(x);
_delay_ms(1000);
}
*/
int lcd_num(int n)
{
int r,s=0;
lcd_cmd(0x04);
while(n>0)
{
r=n%10;
n=n/10;
s=(s*10)+r;
lcd_data(s+48);
_delay_ms(100);
}
lcd_cmd(0x06);
return 0;
}
void lcd_config()
{
lcd_cmd(0x02);
lcd_cmd(0x28);
lcd_cmd(0x0C);
lcd_cmd(0x06);
}
void lcd_cmd(unsigned char x)
{
LCD=x&0xF0;
LCD&=~(1<<LCD_RS);
LCD&=~(1<<LCD_RW);
LCD|=(1<<LCD_EN);
_delay_ms(1);
LCD&=~(1<<LCD_EN);
LCD=(x<<4)&0xF0;
LCD&=~(1<<LCD_RS);
LCD&=~(1<<LCD_RW);
LCD|=(1<<LCD_EN);
_delay_ms(1);
LCD&=~(1<<LCD_EN);
}
void lcd_data(unsigned char y)
{
LCD=y&0xF0;
LCD|=(1<<LCD_RS);
LCD&=~(1<<LCD_RW);
LCD|=(1<<LCD_EN);
_delay_ms(1);
LCD&=~(1<<LCD_EN);
LCD=(y<<4)&0xF0;
LCD|=(1<<LCD_RS);
LCD&=~(1<<LCD_RW);
LCD|=(1<<LCD_EN);
_delay_ms(1);
LCD&=~(1<<LCD_EN);
}
// Timer 1 input capture interrupt service routine
interrupt [TIM1_CAPT] void timer1_capt_isr(void)
{
unsigned char uc_string[10];
unsigned char uc_i;
unsigned int ui_value=0;
uc_i=TCCR1B;
if((uc_i&0b01000000)==0) // ICP Sensing is at falling edge
{
ui_timer=ICR1L; //ICR1 must be readed sequently
ui_value=ICR1H;
ui_value=ui_value<<8;
ui_timer+=ui_value;
ui_value=ui_timer-ui_oldtimer;
lcd_config();
lcd_cmd(0x01);
_delay_ms(100);
lcd_cmd(0x88);
lcd_num(ui_value);
_delay_ms(1000);
//The actual high measurement is in the ui_value variable in micro seconds. Here you have to set your own code
TCCR1B|=0b01000000; //Set ICP Sensing at falling edge
}
else // ICP Sensing is at rising edge
{
TCCR1B&=0b10111111;
ui_timer=ICR1L;
ui_value=ICR1H;
ui_value=ui_value<<8;
ui_timer+=ui_value;
ui_oldtimer=ui_timer;
lcd_config();
lcd_cmd(0x01);
_delay_ms(100);
lcd_cmd(0x88);
lcd_num(ui_value);
_delay_ms(1000);
//The actual low measurement is in the ui_value variable in micro seconds. Here you have to set your own code
}
}
Last edited by a moderator: