基于atmega16的tccr0外部计数.docVIP

  • 18
  • 0
  • 约1.58千字
  • 约 3页
  • 2017-03-15 发布于浙江
  • 举报
基于atmega16的tccr0外部计数

/* * tccr0_waibujishu.c * * Created: 2015/2/6 21:59:15 * Author: Administrator */ ////////////////////////////////////////////////////////////////////////// // 引脚说明 // // PA0~PA7 1~8段 // // PC0~PC3 5~8位 // ////////////////////////////////////////////////////////////////////////// #include #include #include #include #define BIT x 1 x #define uchar unsigned char ////////////////////////////////////////////////////////////////////////// // 数码管宏定义 // #define DDR_SMG_DUAN DDRA // #define PORT_SMG_DUAN PORTA // #define DDR_SMG_WEI DDRC // #define PORT_SMG_WEIN PORTC // ////////////////////////////////////////////////////////////////////////// void shumaguan_chushihua //数码管初始化函数 DDR_SMG_DUAN 0xff; PORT_SMG_DUAN 0; DDR_SMG_WEI 0xff; PORT_SMG_WEIN 0; DDRD ~ BIT 2 ; PORTD| BIT 2 ; DDRB| BIT 3 ; DDRB ~ BIT 0 ; PORTB| BIT 0 ; TCCR0| BIT CS02 |BIT CS01 ; //ctc xiajiangyan GICR| BIT INT0 ; sei ; _delay_ms 1 ; SIGNAL SIG_INTERRUPT0 static int k 1; if k 1 k -1; _delay_ms 1000 ; cli ; set_sleep_mode SLEEP_MODE_PWR_DOWN ; sei ; sleep_enable ; sleep_cpu ; else k 1; _delay_ms 100 ; while PIND|0xfb ! 0xff ; void xianshi_1 char wei_1[] //低四位计数器显示函数 int table[] 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f ;//数码0~9 for char i 0;i 4;i++ PORT_SMG_DUAN table[wei_1[i]]; PORT_SMG_WEIN BIT i ; _delay_ms 0.1 ; PORT_SMG_WEIN 0; _delay_ms 0.9 ; int main void shumaguan_chushihua ; //数码管初始化 int i,j; char wei_1[4] 0 ; while 1 j TCNT0; for i 0;i 4;i++ wei_1[i] j%10; j/ 10; xianshi_1 wei_1 ; //高四位时钟显示

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档