BASIC4MCU | 질문게시판 | atmega128 recipe for target 'main.o ' failed 오류
페이지 정보
작성자 hhhyyyeee 작성일2024-06-19 22:22 조회742회 댓글3건본문
ISR(INT4_vect)
{
if(toggle == 0)
{
pulse_count = 0;
TCCR0= 0x02;
TCNT0= 140;
EICRB= 0x02;
TIMSK = 0x01;
toggle = 1;
}
else
{
EICRB = 0x03;
TIMSK = 0x00;
TCCR0 = 0x00;
toggle = 0;
}
}
이 부분에서 recipe for target 'main.o ' failed 오류가 나는데 이유를 모르겠어요 ㅠㅠ 코드를 어떻게 수정하면 될까요?
댓글 3
조회수 742master님의 댓글
master 작성일
전체 소스코드를 첨부하세요
//
선언하지 않은 변수가 있는지 체크해보세요
hhhyyyeee님의 댓글
hhhyyyeee 작성일
#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>
#include <stdio.h>
#include <avr/interrupt.h>
#define LCD_DB_PORT PORTA
#define LCD_DB_DDR DDRA
#define LCD_CMD_PORT PORTC
#define LCD_CMD_DDR DDRC
#define SW_PORT PORTD
#define SW_DDR DDRD
#define SW_PIN PIND
#define US_PORT PORTE
#define US_DDR DDRE
#define BUZZER_PORT PORTF
#define BUZZER_DDR DDRF
#define DIST_MIN 4
#define DIST_MAX 50
#define HEIGHT_MIN 15
#define HEIGHT_MAX 35
#define YES 12
#define NO 34
volatile unsigned int pulse_count = 0;
volatile unsigned char togle = 0;
unsigned char UP_flag = NO;
unsigned char DOWN_flag = NO;
char str[16];
void pulse(void)
{
US_PORT = 0x01;
_delay_us(10);
US_PORT = 0x00;
}
ISR(TIMER0_OVF_vect)
{
pulse_count++;
TCNT0 = 140;
}
ISR(INT4_vect)
{
if(togle == 0)
{
pulse_count = 0;
TCCR0= 0x02;
TCNT0= 140;
EICRB= 0x02;
TIMSK = 0x01;
togle = 1;
}
else
{
EICRB = 0x03;
TIMSK = 0x00;
TCCR0 = 0x00;
togle = 0;
}
}
void LCD_cmd(unsigned char cmd)
{
LCD_CMD_PORT = 0x00;
LCD_DB_PORT = cmd;
LCD_CMD_PORT = 0x01;
_delay_us(1);
LCD_CMD_PORT = 0x00;
_delay_us(100);
}
void LCD_init(void)
{
LCD_cmd(0x38);
LCD_cmd(0x0C);
LCD_cmd(0x06);
LCD_cmd(0x01);
_delay_ms(2);
}
void LCD_data(unsigned char data)
{
LCD_CMD_PORT = 0x02;
LCD_DB_PORT = data;
LCD_CMD_PORT = 0x03;
_delay_us(1);
LCD_CMD_PORT = 0x02;
_delay_us(100);
}
void LCD_print(unsigned char cmd, char *str)
{
LCD_cmd(cmd);
while(*str != 0)
{ LCD_data(*str);
str++;
}
}
void LCD_char_print(unsigned char cmd, char *str)
{
LCD_cmd(cmd);
LCD_data(*str);
}
void Title_display(void)
{
LCD_print(0x80,"[PUSHUP COUNTER]");
LCD_print(0xC0," PRESS ANY KEY..");
}
void Buzzer_short(void)
{
BUZZER_PORT = 0x01;
_delay_ms(10);
BUZZER_PORT = 0x00;
}
void Buzzer_long(void)
{
BUZZER_PORT = 0x01;
_delay_ms(100);
BUZZER_PORT = 0x00;
}
void Counting_mode(void)
{
unsigned int num = 0;
sprintf(str," %u ",num);
LCD_print(0x80," COUNTING ");
LCD_print(0xC0,str);
while(1)
{
pulse();
_delay_ms(60);
if(pulse_count > DIST_MIN && pulse_count < DIST_MAX)
{
if(UP_flag == NO && pulse_count > HEIGHT_MAX)
{
UP_flag = YES;
}
if(UP_flag == YES && pulse_count < HEIGHT_MIN)
{
UP_flag = NO;
DOWN_flag = YES;
}
if(DOWN_flag == YES && pulse_count > HEIGHT_MAX)
{
DOWN_flag = NO;
Buzzer_short();
sprintf(str," %u ",++num);
}
}
if(SW_PIN == 0b00000000)
{
_delay_ms(20);
num = 0;
Buzzer_long();
sprintf(str," %u ",num);
}
LCD_print(0xC0,str);
}
}
void Port_Setting()
{
LCD_DB_DDR = 0xFF;
LCD_DB_PORT = 0x00;
LCD_CMD_DDR = 0xFF;
LCD_CMD_PORT = 0x00;
SW_DDR = 0xF0;
SW_PORT = 0x01;
US_DDR = 0x0F;
US_PORT = 0x00;
BUZZER_DDR = 0x0F;
BUZZER_PORT = 0x00;
}
int main(void)
{
Port_Setting();
LCD_init();
_delay_us(50);
EICRB = 0x03;
EIMSK = 0x10;
ACSR = 0x80;
sei();
Title_display();
while(1)
{
if(SW_PIN == 0b00000000)
{
_delay_ms(20);
Buzzer_long();
Counting_mode();
}
}
} 이게 전체 코드입니다! ㅠㅠ lcd_print 부분에서도 오류가 나는데 뭐가 문제인지 모르겠어요 ㅠㅠㅠ
master님의 댓글
master 작성일
AVRstudio4에서 오류 발생하지 않습니다.
새프로젝트 만들기로 다시 컴파일 해보세요