microsoho 发表于 2012-12-6 09:13:31

mega328p 定时器2编译时出现TCCR2,OCR2,SFIOR寄存器未定义

编译器用的是winavr,MCU类型是atmega328p
先随便写个程序验证
#include<avr/io.h>
int main(void)
{
        OCR2=0X4A;
        SFIOR=0X08;
        TCCR2=0X7A;
        while(1);
}
编译时出现下面错误提示:
example.c:5:error:'OCR2' undeclared (first use in this function)
example.c:5:error:(Each undecleared identifier is reported only once)
example.c:5:error:for each funtion it appears in.)
example.c:6:error:'SFIOR' undeclared (first use in this function)
example.c:5:error:'TCCR2' undeclared (first use in this function)

我把mcu类型改为atmega8时,竟然便已通过了。各位大虾,能不能指点一二

microsoho 发表于 2012-12-6 15:59:50

我弄错了,TCCR2在atmega328p中有2个寄存器
页: [1]
查看完整版本: mega328p 定时器2编译时出现TCCR2,OCR2,SFIOR寄存器未定义