?? time.c
字號:
#include "time.h"
#include <iom16.h>
volatile unsigned char SampleTimeFlag;
volatile unsigned long DelayTime;
volatile unsigned char InDelayTime;
volatile unsigned char TimeOver;
//TIMER0 initialisation - prescale:1024
// WGM: Normal
// desired value: 10mSec
// actual value: 9.984mSec (0.2%)
void Timer0Init(void)
{
TCCR0 = 0x00; //stop
TCNT0 = 0xB9; //set counter //for 7.3728MHz
TIMSK|=0x01; //Enable interrupt
TCCR0 = 0x05; //start timer
}
#pragma vector=TIMER2_OVF_vect
__interrupt void Timer2_ovf_isr(void)
{
TCNT2 = 0x64; //reload counter value
SampleTimeFlag=1;
}
//TIMER2 initialize - prescale:256
// WGM: Normal
// desired value: 5mSec
// actual value: 4.965mSec (0.7%)
void Timer2Init(void)
{
TCCR2 = 0x00; //stop
ASSR = 0x00; //set async mode
TCNT2 = 0x64; //setup
OCR2 = 0x9C;
TCCR2 = 0x06; //start
SampleTimeFlag=0;
TIMSK |=1<<TOIE2;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -