昨天就写了个程序就是定时器的中断程序,结果,就是近不了中断 ,用的atmega48的片子 程序如下:
/*
* STATICLCD.c
*
* Created: 2011-10-24 12:05:23
* Author: yangcw
*/
#include <avr/io.h>
#include <avr/interrupt.h>
const int seg[10]={0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char num;
void init(void)
{
DDRB=0xff;
PORTB=0x00;
DDRC&=0x00;
}
void timer1_init(void)
{
cli();
TCCR1B=0x00;
TCCR1A=0x00;
TCNT1H=0x85;
TCNT1L=0xee;
TCCR1B=0x04;
TIMSK1=0x01;
}
void delay(int j)
{
int a,b;
for (a=0;a<j;a++)
for (b=0;b<200;b++);
}
}
void main(void)
{
cli();
init();
timer0_init();
sei();
while(1)
{
DDRC|=0x01;
PORTB=~seg[num];
PORTC|=0x01;
delay(2);
PORTB=seg[num];
PORTC&=0x00;
delay(2);
DDRC&=0x00;
delay(5);
}
}
#pragma interrupt_handler Timer1_isr:14
void Timer1_isr(void)
{
TCNT1H=0x85;
TCNT1L=0xEE;
num++;
if (num==10)
{
num=0;
}
就是不能进入中断 求大侠帮帮忙~~~郁闷了两天~~
}*/ |