📄 macclock.c
字号:
/*
****************************************************************************
* 宁波中科集成电路设计中心 版权所有 Copyright 2005
* http:\\www.nbicc.com
*文件名: mac.c
*程序员: 夏鹏 xpsonny@nbicc.com
*主要内容 定时器
*如有问题或BUG,请登录www.wsn.net.cn 提问或用邮件和作者联系
****************************************************************************
*/
#include "macClock.h"
#include "os.h"
#include "led.h"
#include "mac.h"
#include <inttypes.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
#define SCALE_1ms 2
#define INTERVAL_1ms 45000//15000 // 7650
void ClockStart(void)
{
uint8_t intEnabled, scale = SCALE_1ms;
uint16_t interval = INTERVAL_1ms;
scale |= 0x8;
cbi(TIMSK, OCIE1A); // 关比较器A的输出中断
intEnabled = bit_is_set(SREG, 7);
cli(); // 访问寄存器前先关中断
outw(TCNT1L, 0); // 清空寄存器
outw(OCR1AL, interval); // 设置比较匹配寄存器
if (intEnabled)
sei();
outp(scale, TCCR1B); // 设置为8分频
sbi(TIMSK, OCIE1A); // 开中断
}
//48ms一次中断
SIGNAL(SIG_OUTPUT_COMPARE1A) // 中断服务程序
{
MACClockFire();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -