中级会员
 
- 积分
- 483
- 金钱
- 483
- 注册时间
- 2013-7-27
- 在线时间
- 4 小时
|
5金钱
实在找不出问题在哪里,先列出我的程序,麻烦各位大侠帮我看一下,非常感谢!
// 功能:每隔1秒,PB口的8个led状态改变一次
#include <string.h>
#include <stdio.h>
#define F_CPU 7372800 /* 单片机主频为7.3728MHz,用于延时子程序 */
#include <util/delay.h>
#include <avr/io.h>
//#include<iom16v.h>
//#include<macros.h>
#pragma interrupt_handler timer1_interrupt:9
#define LED8   ORTB
#define uint unsigned int
#define uchar unsigned char
void system_init()
{
DDRB=0xff; //设置PD口为输出
LED8=0xff;
}
void Timer1_Init()
{
TCCR1A = 0x00;
TCCR1B = 0x04; //256分频
// 7372800/256 = 28800 = 0x70 80
TCNT1H = 0x70;
TCNT1L = 0x80;
TIMSK |= 0x04;
SREG |= 0x80;
}
void main()
{
system_init(); //系统初始化
Timer1_Init();
while(1);
}
void timer1_interrupt()
{
LED8 = ~LED8;
}
|
|