BASIC4MCU | 질문게시판 | avr studio -> codevision 코드로 바꾸고 싶습니당 ㅜㅜ
페이지 정보
작성자 쥬니 작성일2019-06-12 23:42 조회4,584회 댓글1건본문
avr studio로 작성한 코드를 codevisionAVR에서 구동가능하게 코드 변형을 하고 싶은데 ㅜㅜ 제발 도와주세요!!
#include<avr/io.h>
#include< avr/interrupt.h>
#define TRUE 1
#define FALSE 0
volatile char bLED = TRUE;
volatile int TimeCounter = 0; // 카운트를 세기위한 변수
volatile char LEDdigit[4] = {0,0,0,0}; // LED에 켜져야 할 값 설정
char number[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x27, 0x7f,0x67};
char Dotnumber[10]={0xBf,0x86,0xDb,0xCf,0xE6,0xEd,0xFd,0xA7, 0xFf,0xE7};
void SetLED(int Time);
// Timer1번의 컴페어 인터럽트, 0.1초마다 인터럽트를 걸어준다.
ISR(TIMER1_COMPA_vect)
{
TimeCounter++; // 0.1초마다 카운터를 증가시킨다.
if(bLED == TRUE)
{
SetLED(TimeCounter);
}
}
// LED를 켜는 인터럽트 , 16bit카운터를 사용하였다.
ISR(TIMER3_COMPA_vect)
{
static char index = 0;
static char ctrl[4] = { ~0x08, ~0x04, ~0x02, ~0x01};
index++;
index &= 0x3; // 0,1,2,3
PORTC = ctrl[index];
PORTA = LEDdigit[index];
}
void SetLED(int Time)
{
if(Time<9999) {
int i ;
i = Time/1000;
LEDdigit[3] = number[i];
Time -= i * 1000;
i = Time/100;
LEDdigit[2] = number[i];
Time -= i * 100;
i = Time/10;
LEDdigit[1] = Dotnumber[i];
Time -= i * 10;
i = Time;
LEDdigit[0] = number[i];
}
Else
{
LEDdigit[0] = number[1];
LEDdigit[1] = number[2];
LEDdigit[2] = Dotnumber[2];
LEDdigit[3] = number[1];
}
}
int main()
{
bLED = TRUE;
TimeCounter = 0;
DDRC = 0x0f;
DDRA = 0xff;
DDRG = 0x03;
TCCR1A = 0x00;
TCCR1B = 0x0C;
TCCR1C = 0x00;
OCR1A = 6249;
TCNT1 = 0x0000;
TCCR3A = 0x00;
TCCR3B = 0x0C;
TCCR3C = 0x00;
OCR3A = 250;
TCNT3 = 0x0000;
TIMSK = 0x10;
ETIMSK = 0x10;
TIFR = 0x00;
ETIFR = 0x00;
sei();
while(1)
{
if(PING&0x04)
{
if(bLED == TRUE) bLED = FALSE;
else bLED = TRUE;
while(PING&0x04) {}
}
if(PING&0x08)
{
TimeCounter = 0;
SetLED(TimeCounter);
while(PING&0x08) {}
}
}
return 0;
}
댓글 1
조회수 4,584master님의 댓글
master 작성일
Else
{
엉터리 문법이 있는 것을보니 컴파일 오류 체크가 안된 소스군요
미완성 소스인가요?
else는 대문자가 있으면 안됩니다.(c언어는 대소문자를 구별합니다.)