avr studio 4 에서 빌드를 하는데 자꾸 에러하나가 뜹니다 ㅜ;
오류내용은
../uuju87.c:2:20: fatal error: my_def.h: No such file or directory
compilation terminated.
make: *** [uuju87.o] 오류 1
Build failed with 1 errors and 0 warnings...
이런식인데요 .. 툴체인을 사용안하고 avr+winavr 조합으로 빌드를 돌려봐도 안되네요 ..
가스센서를 이용해서 반응을 lcd,led,부저로 출력하는 프로그램인데
소스좀 봐주시면 감사하겠습니다 ;;
소스내용
------------------------------------------------------------------------------------
#include<avr/io.h>
#include "my_def.h"
void busy_check(void);
void LCD_init(void);
void msec_delay(u16);
void cmd_write(u08);
void data_write(u08);
void string_out(u08, u08, u08 []);
void LCD_2d1(float number);
//void LCD_4hex(unsigned int number);
u16 i;
u08 temp;
/*void msec_delay(u16 msec)
{
while(msec--)
{
for(u16 i=0;i<4000;i++);
};
}*/
void busy_check(void)
{
PORTC &= 0xfe; //rs = 0
PORTC |= 0x02; //r/w = 1
PORTC |= 0x04; //e = 1
DDRD &=0x7f; //input
do{
temp = PIND;
}while(temp & 0x80);
PORTC &= 0xf8; //rs,r/w,e = 0
DDRD |=0x80; //output
}
void cmd_write(u08 cmd)
{
busy_check();
PORTC &= 0xfb; // rs 0
PORTC &= 0xfd; //r/w = 0
PORTC |= 0x04; // e = 1
PORTD = cmd&0xf0; //상위4비트 출력
PORTC &= 0xfb;
PORTC |= 0x04;
PORTD = (cmd<<4)&0xf0; //하위4비트 출력
PORTC &= 0xfb; // e = 0
PORTC |= 0x04; // e = 1
PORTC |= 0x02; // r/w = 1
msec_delay(50);
}
void data_write(u08 dat)
{
busy_check();
PORTC |= 0x01;
PORTC &= 0xfd;
PORTC |= 0x04;
PORTD = dat&0xf0;
PORTC &= 0xfb;
PORTC |= 0x04;
PORTD = (dat<<4)&0xf0;
PORTC &= 0xfb;
PORTC |= 0x02;
msec_delay(50);
}
void string_out(u08 i, u08 j, u08 str[16]) //문자열 출력 함수
{
if(i == 0)
cmd_write(0x80+j); //address 설정
else if(i == 1)
cmd_write(0xc0+j); //address 설정
while(*str != '\0'){
data_write(*str);
str++;
}
}
void LCD_2d1(float number)
{
unsigned int i, j;
j=(int)(number*100.+0.5);
i=j/1000;
data_write(i+'0');
data_write('.');
j=j%1000;
i=j/100;
data_write(i+'0');
j=j%100;
i=j/10;
data_write(i+'0');
}
void LCD_init(void)
{
DDRD = 0xf0;
DDRC = 0x0f;
cmd_write(0x28); // interface set : 4bit
msec_delay(50);
cmd_write(0x28); // interface set : 4bit
msec_delay(50);
cmd_write(0x08); // display on/off control
msec_delay(50);
cmd_write(0x06); //LCD ENTRY MODE SET : shift off
cmd_write(0x01); //Entry display Clear, Cursor return to home
msec_delay(100);
}
#include <avr/io.h>
#include <avr/interrupt.h>
#include "my_def.h"
#define COUNT_SELECT (65535 - CPU_CLOCK/1000) // for 1 msec
void init_system_clock(void);
//Atmega8 - one 16 bit timer/counter & two 8 bit timer/counter
u16 msec;
u08 mmsec, csec, dsec, sec, min, hour, day, month, year;
u08 msec_flag, csec_flag, dsec_flag, sec_flag, min_flag; //flag
void init_system_clock(void)
{
TCCR1A = 0x00; // PWM Disable
TCCR1B = 0x01; // no prescaling
// TCCR1B = 0x02; // 1/8 orescaling(14,745,600/8=1, 843, 200hz)
TCNT1 = COUNT_SELECT;
TIMSK = 0x04; // enable overflow interrupt
msec = mmsec = csec = dsec = sec = min = 0;
msec_flag = csec_flag = dsec_flag = sec_flag = min_flag = 0;
}
SIGNAL(SIG_OVERFLOW1) //OVERFLOW INTERRUPT SERVICE
{
msec++;
msec_flag = 1;
if(msec == 1000) msec = 0;
mmsec++;
TCNT1 = COUNT_SELECT;
if(mmsec == 10) {
csec++;
csec_flag = 1;
mmsec = 0;
if(csec == 10) {
dsec++;
dsec_flag = 1;
csec = 0;
if(dsec == 10) {
sec++;
sec_flag = 1;
dsec = 0;
msec = 0;
if(sec == 60) {
min++;
min_flag = 1;
sec = 0;
if(min ==60) {
hour++;
min = 0;
};
};
};
};
};
}
#include <avr/io.h>
#include <avr/signal.h>
#include <avr/interrupt.h>
#include "my_def.h"
void init_adc(u08);
extern u08 dsec_flag;
u16 adc;
void init_adc(u08 adc_ch)
{
ADMUX = adc_ch; //기준전압, ADC선택
ADCSRA = 0xef; //A/D 컨버터 동작허용, 시작, 프리러닝모드,인터럽트 허용
}
SIGNAL(SIG_ADC) //인터럽트 서비스 루틴(A/D컨버전 완료시 인터럽트 발생)
{
adc = ADCW; //변환값 ADC변수에 저장
}
#include <avr/io.h>
#include <avr/interrupt.h>
#include "my_def.h"
int main(void);
void init(void);
void msec_delay(u16);
void do_gas(void);
#define BUTTON1 0x01 //버턴입력포트 설정
#define BUTTON1_READ PIND & BUTTON1
extern void init_adc(u08);
extern void init_system_clock(void);
//// LCD /////
extern void busy_check(void);
extern void LCD_init(void);
extern void cmd_write(u08);
extern void data_write(u08);
extern void string_out(u08, u08, u08 []);
extern void LCD_2d1(float);
//extern void LCD_4hex(u08);
//////Timer/////////////
extern u16 msec;
extern u08 mmsec, csec, dsec, sec, min, hour, day, month, year;
extern u08 msec_flag, csec_flag, dsec_flag, sec_flag, min_flag; // flag
u08 cpu_id;
u16 adc;
u16 i;
u08 temp;
int main(void)
{
init();
string_out(0,1,"Alchol Test");
string_out(1,1,"Alram OFF");
msec_delay(1000);
cmd_write(0x0c); //display on
while(1)
{
do_gas();
}
}
void do_gas(void)
{
u16 alchol;
float fadc=0;
float d_alchol=0;
float sum=0;
if(!(BUTTON1_READ))
{
while(1)
{
if(sec==3)
{
PORTB= 0x10;
msec_delay(2000);
PORTB = 0x00;
msec_delay(2000);
alchol = adc;
fadc = alchol;
d_alchol = (fadc);
cmd_write(0x8c); //LCD Address 지정
sum = (fadc/1000);
LCD_2d1(sum); //ADC값 LCD 표시
msec_delay(100);
string_out(0,1,"ready to ");
string_out(1,1,"Testing.... ");
msec_delay(50000);
//msec_delay(50000);
//msec_delay(50000);
//msec_delay(50000);
if( alchol >= 200)
{
PORTB =0x04; //RED LED ON
//PORTC |= 0x08; // BUZZ ON
string_out(0,1,"Detecting:");
string_out(1,1,"Non Passing!");
msec_delay(1000) ;
sec=0;
PORTB= 0x14;
msec_delay(2000);
PORTB = 0x00;
msec_delay(2000);
PORTB= 0x14;
msec_delay(2000);
PORTB = 0x00;
msec_delay(5000);
}
else if(alchol >= 150)
{
PORTB=0x02; // YELLOW LED ON
msec_delay(1000);
string_out(0,1,"Detecting:");
string_out(1,1,"Caution!! ");
sec_flag=0;
PORTB= 0x12;
msec_delay(2000);
PORTB = 0x00;
msec_delay(2000);
PORTB = 0x12;
msec_delay(2000);
PORTB = 0x00;
msec_delay(2000);
}
else
{
//Green LED ON
string_out(0,1,"Detecting:");
string_out(1,1,"you can go home");
msec_delay(1000);
sec_flag=0;
PORTB =0x01;
msec_delay(2000);
}
}
}
}
}
void msec_delay(u16 msec)
{
while(msec--) {
for(u16 i=0;i<10000;i++);
};
}
void init(void)
{
DDRC = 0x0f; // set Port_C to Output
DDRD |= 0xf0; // set Port_D to Output
PORTD &= 0x01;
DDRF = 0x00;
DDRB = 0x1f; // set Port_B to Output
msec_delay(10); // dummy delay for stable
init_system_clock();
LCD_init();
init_adc(5);
msec_delay(1000);
sei();
}
my_def.h 를 못찾고 있네요
AVRstudio 좌측에 보면 header file 부분 우 클릭후 add 후 my_def.h 파일을 찾아서 넣어주면 될듯하네요