[ATMEGA128] 레포트


#include<avr/io.h>
#include<avr/interrupt.h>
#include<avr/signal.h>

volatile unsigned int TIC_TIME;

void init_port(void){
        DDRF=0xFF;
        PORTF=0x00;
}
void init_timer1(void){
        TCNT1H=0;
        TCNT1L=0;
        TCCR1A=0x00;
        TCCR1B=0x0C;
        TCCR1C=0x00;

        OCR1AH=0xF4;
        OCR1AL=0x24;
        TIMSK=TIMSK|(1<<OCIE1A);
}

void init_timer(void){
        TIFR=0x00;
        init_timer1();
}
void init(void){
        init_port();
        init_timer();
}

SIGNAL(SIG_OUTPUT_COMPARE1A){
        TIC_TIME++;
}
int main(void){
        init();
        sei();
        while(1){
                if(TIC_TIME>99){
                        TIC_TIME=0;
                        PORTF=0x00;
                }
                else
                        PORTF=(TIC_TIME/10)<<4||TIC_TIME%10;
        }

        return 0;
}


Posted by rCan

2008/12/09 17:25 2008/12/09 17:25
Response
No Trackback , No Comment
RSS :
http://rcan.net/rss/response/585

Trackback URL : http://rcan.net/trackback/585

Leave a comment
« Previous : 1 : ... 8 : 9 : 10 : 11 : 12 : 13 : 14 : 15 : Next »

블로그 이미지

- rCan

Calendar

«   2010/09   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    

Notices

  1. About Me

Recent Posts

Site Stats

Total hits:
89710
Today:
20
Yesterday:
42