|
用ATmel Studio6.2编译出错,ATmega16的T/C0例程
[复制链接]
我最近在学习AVR单片机,我参考《AVR单片机使用C语言程序设计与典型实例》书上的例程来学习,但是我使用Atmel Studio6.2编译书上的T/C0例程时,出错了,是什么原因呢?
- #define F_CPU 4000000UL
- #include <avr/io.h>
- //#include <iom16.h>
- #include <util/delay.h>
- #include <avr/interrupt.h>
- #define uchar unsigned char
- #define uint unsigned int
- const uchar LedNum[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
- uchar second = 0;
- uchar count = 0;
- uchar minute = 0;
- void LEDShow(int num)
- {
- uchar i,tmp,curnum;
- int tmpnum;
- tmp=0xef;
- tmpnum=num;
- for (i=0;i<4;i++)
- {
- curnum = tmpnum % 10;
- curnum = tmpnum / 10;
- PORTA =tmp;
- if (i==2)
- {
- PORTC=LedNum[curnum]|0x80;
- }
- else
- {
- PORTC=LedNum[curnum];
- }
- _delay_ms(1);
- tmp = (tmp<<1);
- }
- }
- int main(void)
- {
- DDRC = 0XFF;
- DDRA = 0XFF;
- DDRB = 0X01;
- TCCR0 = 0X05;
- TIMSK = 0X01;
- TCNT0 = 256 - 0.01/(1024.0/F_CPU);
- sei();
- while(1)
- {
- LEDShow(minute*100+second);
- if (second>59)
- {
- second = 0;
- minute ++;
- }
- if (minute>99)
- {
- minute=0;
- }
- }
- return 0;
- }
- SIGNAL(SIG_OVERFLOW0)
- {
- count++;
- if (count == 99)
- {
- second++;
- count=0;
- }
- TCNT0=256 - 0.01/(1024.0/F_CPU);
- }
复制代码 编译错误是:Error 1 attempt to use poisoned "SIG_OVERFLOW0"
|
|