最近自学avr买了一本马潮老师的书折腾两天都没折腾过去,avr,编译环境cvavr,16m晶振
我想做一个利用定时器产生脉冲来控制两个led灯闪烁可是,能够编译过去,但是灯一直就亮着不闪烁。大家看看那里粗问题了/***************************...
我想做一个利用定时器产生脉冲来控制两个led灯闪烁可是,能够编译过去,但是灯一直就亮着不闪烁。大家看看那里粗问题了
/*****************************************************
This program was produced by the
CodeWizardAVR V2.05.1b Evaluation
Automatic Program Generator
?Copyright 1998-2011 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date : 2014/10/5
Author : Freeware, for evaluation and non-commercial use only
Company :
Comments:
Chip type : ATmega16A
Program type : Application
AVR Core Clock frequency: 16.000000 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 256
*****************************************************/
#include <mega16a.h>
int ji=0;
interrupt[TIM0_OVF]void time0_ovf_isr(void)
{
TCNT0=0X83;
ji=ji++;
PORTB.0=~PORTB.0;
}
// Declare your global variables
void main(void)
{
PORTB.0=0;
DDRB.0=1;
PORTB.2=0;
DDRB.2=1;
TCCR0=0X07;
TCNT0=0X83;
OCR0=0X00;
TIMSK=0X01;
#asm("sei")
while (1)
{
if(ji>1000)// Place your code here
{ji=0;
PORTB.2=~PORTB.2;}
}
} 展开
/*****************************************************
This program was produced by the
CodeWizardAVR V2.05.1b Evaluation
Automatic Program Generator
?Copyright 1998-2011 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date : 2014/10/5
Author : Freeware, for evaluation and non-commercial use only
Company :
Comments:
Chip type : ATmega16A
Program type : Application
AVR Core Clock frequency: 16.000000 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 256
*****************************************************/
#include <mega16a.h>
int ji=0;
interrupt[TIM0_OVF]void time0_ovf_isr(void)
{
TCNT0=0X83;
ji=ji++;
PORTB.0=~PORTB.0;
}
// Declare your global variables
void main(void)
{
PORTB.0=0;
DDRB.0=1;
PORTB.2=0;
DDRB.2=1;
TCCR0=0X07;
TCNT0=0X83;
OCR0=0X00;
TIMSK=0X01;
#asm("sei")
while (1)
{
if(ji>1000)// Place your code here
{ji=0;
PORTB.2=~PORTB.2;}
}
} 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
若以下回答无法解决问题,邀请你更新回答
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询