|
//ICC-AVR application builder : 2010-11-1 20:57:36 // Target : M8 // Crystal: 1.0000Mhz #include #include #define uchar unsigned char #define uint unsigned int #define ulong unsigned long #define LED_N 10 //10位显示 //---------------------------------- #define Bit(n) (1<//LED_RUN #define led_on() PORTD&=~Bit(PD3) #define led_off() PORTD|=Bit(PD3) #define led_run() PORTD^=Bit(PD3) //定义74HC595时钟、数据、锁存、使能引脚状态 #define CLK_H() PORTB|=BIT(PB6) #define CLK_L() PORTB&=~BIT(PB6) #define DAT_H() PORTB|=BIT(PB7) #define DAT_L() PORTB&=~BIT(PB7) #define RCK_H() PORTB|=BIT(PB2) #define RCK_L() PORTB&=~BIT(PB2) #define ENA_H() PORTB|=BIT(PB1) #define ENA_L() PORTB&=~BIT(PB1)
//0, 1, 2, 3, 4, 5 , 6, 7, 8, 9, A, B, C, D, E, F const uchar led_array[27]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e, //- dark S H Y E n , P , L , ,r25 ,o26 0xbf,0xff,0x92,0x89,0x91,0x86,0xab,0x8c,0xc7,0xaf,0xa3}; //共阳管 uchar Led_Set_buf[LED_N]; uint count; /**************************************************************** //函数名称:delay_1ms(void) //功 能:延时1ms //入口参数:无 //出口参数:无 //说明:for(i=1;i<(unsigned int)(xtal*143-2_;i++)xtal为晶振频率,单位为MHz。 *****************************************************************/ void delay_1ms()//1ms { uint i; for(i=1;i<(uint)(1*143-2);i++); } /**************************************************************** //函数名称:delay_ms(uint time) //功 能:延时time ms //入口参数:time //出口参数:无 *****************************************************************/ void delay_ms(uint time)//time*1ms { uint i; while(i |
|