?? 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 + -