BASIC4MCU | 질문게시판 | 아트메가질문이요!!
페이지 정보
작성자 hello0 작성일2021-12-09 19:19 조회531회 댓글3건본문
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdio.h>
#include <math.h>
#include <util/delay.h>
#define DIGITS 4
const char a[10] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x67};
void delay_us(unsigned int time_us) // Time delay For 1us(8MHz)
{
register unsigned int i;
for(i=0; i<time_us; i++){ // 4 cycle+
asm volatile("PUSH R0"); // 2 cycle+
asm volatile("POP R0"); // 2 cycle = 8cycle = 1us
} // for 8MHz
}
void delay_ms(unsigned int time_ms)
{
register unsigned int i;
for(i=0; i<time_ms; i++){
delay_us(1000);
}
}
int main(void)
{
char in,out;
char Digit[3];
int CountNo=0, DelayTime=1;
int CountKeyPress=0;
int i=0;
DDRG=0x03;
DDRA=0xff;
DDRC=0xff;
while(1){
while (CountKeyPress>1000)
{
if(++CountNo>999){ CountNo=0; } // 이 코드를 추가하면 자동으로 증가
in=PING;
in&=0x0c; //mask
if(in==0x04){ // 100의자리 증가
i=CountNo%1000/100; // 100의 자리 추출해서 i에 넣음
CountNo-=i*100; // 100의자리를 삭제
if(++i>9)i=0; // 오버플로우 시 0으로
CountNo+=i*100; // 100의자리를 갱신
}
else if(in==0x08){ // 10의자리 증가
i=CountNo%100/10; // 10의 자리 추출해서 i에 넣음
CountNo-=i*10; // 10의자리를 삭제
if(++i>9)i=0; // 오버플로우 시 0으로
CountNo+=i*10; // 10의자리를 갱신
}
else{
if(++CountNo>999){ CountNo=0; } // 이 코드를 추가하면 자동으로 증가
}
CountKeyPress=0;
Digit[0]=CountNo%10;
Digit[1]=(CountNo/10)%10;
Digit[2]=(CountNo/100)%10;
}
CountKeyPress++;
if(CountNo>99){
PORTC=0xfd; //1111 1101
PORTA=a[Digit[2]];
}
_delay_ms(DelayTime);
if(CountNo>9){
PORTC=0xfb; //1111 1011
PORTA=a[Digit[1]];
}
_delay_ms(DelayTime);
PORTC=0xF7; //1111 0111
PORTA=a[Digit[0]];
_delay_ms(DelayTime);
}
return 0;
}
코드를 이렇게 썼는데 에러가 납니다ㅠㅠ
어디가 잘못된지를 모르겠습니다
Build started 9.12.2021 at 19:01:36
make: Makefile: No such file or directory
make: *** No rule to make target `Makefile'. Stop.
Build failed with 2 errors and 0 warnings...
댓글 3
조회수 531master님의 댓글
master 작성일
새프로젝트 만드는 법을 공부하세요
그 후 새 프로젝트의 소스파일에 질문코드를 복사해서 컴파일 해보세요
hello0님의 댓글
hello0
새프로젝트 만드는 법은 어디서 보나여ㅛ?
네이버에 쳐보니 c언어밖에 안나와서요
master님의 댓글
master
컴파일러 설치하는 설명글을 읽어보면 새 프로젝트 만드는 설명까지 들어있는 것이 있을겁니다.
https://www.google.com/search?q=avr+studio+4.19+%EC%83%88+%ED%94%84%EB%A1%9C%EC%A0%9D%ED%8A%B8&oq=avr+studio+4.19+%EC%83%88+%ED%94%84%EB%A1%9C%EC%A0%9D%ED%8A%B8&aqs=chrome..69i57j0i333l3.19670j0j7&sourceid=chrome&ie=UTF-8