?? blance._h
字號:
#include <iom32v.h>
#include "linecheck.h"
unsigned int flag=1;
unsigned int temp;
unsigned int T=1000;
unsigned int i=0;
/*延時子程序*/
/*void delay_ms(int time)
{
int i;
for(;time>0;time--)
for(i=0;i<1000;i++);
}*/
端口初始化*/
void port_init()
{
PORTA = 0XFF;
DDRA = 0x00;//PA 為輸入口
PORTB = 0x00;
DDRB = 0xff;//PB 為輸出口
PORTC = 0Xff;
DDRC = 0x00;//PC 為輸入口
DDRD=0XF7;
PORTD=0X08;
}
/*中斷初始化*/
void INT1_init()
{
SREG=0x80; /*使能全局中斷*/
//MCUCR&=~((1<<ISC01)|(1<<ISC00)); /*低電平觸發中斷*/
MCUCR=0x0C;
GICR=(1<<INT1); /*使能外部中斷1請求*/
}
//TIMER0 initialize - prescale:64
// WGM: Normal
// desired value: Hz
// actual value: Out of range
void timer0_init(void)
{
TCCR0 = 0x00; //stop
TCNT0 = 0x00 /*INVALID SETTING*/; //set count
OCR0 = 0x00 /*INVALID SETTING*/; //set compare
TCCR0 = 0x02; //start timer
}
/*中斷服務程序*/
#pragma interrupt_handler int1:4
void int1()
{
/*unsigned char i;
for(i=0;i<8;i--) //去
{
//PORTB=~(1<<i);
PORTB=0x00;
delay_ms(5);
}*/
if(flag)
{
timer0_init();
temp=TCNT0;
MCUCR=0x08;
flag=0;
//delay_ms(80);
}
else
{
TCCR0 = 0x00;
temp=TCNT0-temp;
MCUCR=0x0c;
flag=1;
// delay_ms(80);
// INT1_init();
// SREG=0x00;
//GICR=0x00;
}
}
/*流水燈顯示*/
/*void display()
{
unsigned char i;
if(temp!=0) //去
{
//PORTB=~(1<<i);
PORTB=temp;
//delay_ms(10);
}
}*/
void blance(void)
{
if(temp<0x9f)
BACK(600) ;
if(temp>0xa0)
Linecheck_GO();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -