我为了使用ATtiny45定时器1作每秒1000HZ的定时中断,编了以下程序,可是运行不了,想了好久也想不出解决的方法。请各位高手指导,看看问题出在哪里?
#include <tiny45.h>
#define uchar unsigned char
#define uint unsigned int
#define led PORTB.0
#define LED_ON 0
#define LED_OFF 1
uint mark = 0;
// Timer1 overflow interrupt service routine
interrupt [TIM1_OVF] void timer1_ovf_isr(void)
{
// Reinitialize Timer1 value
TCNT1=0x64;
// Place your code here
mark++;
}
void main(void)
{
PORTB=0x03;
DDRB=0x01;
// Timer/Counter 1 initialization
PLLCSR=0x00;
TCCR1=0x01;
GTCCR=0x00;
TCNT1=0x64;
OCR1A=0x00;
OCR1B=0x00;
OCR1C=0x00;
// Interrupt(s) initialization
TIMSK=0x04;
while(1)
{
if(mark==500)
led = LED_ON;
if(mark==1000)
led = LED_OFF;
mark = 0;
}
} |