欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: AVR定時0 [打印本頁]

作者: 225631    時間: 2013-7-22 15:18
標題: AVR定時0
//ICC-AVR application builder : 2013-7-18 下午 08:03:54
// Target : M128
// Crystal: 16.000Mhz
#include <iom128v.h>
#include <macros.h>
typedef unsigned char uchar;
uchar i;
void port_init(void)
{
PORTA = 0xff;
DDRA  = 0xff;
PORTE = 0xff;
DDRE  = 0xff;
}
//TIMER0 initialize - prescale:1024
// WGM: Normal
// desired value: 10mSec
// actual value:  9.984mSec (0.2%)
void timer0_init(void)
{
TCCR0 = 0x00; //stop
ASSR  = 0x00; //set async mode
TCNT0 = 0x01; //set count
OCR0  = 0x4f;
TCCR0 = 0x07; //start timer
}
#pragma interrupt_handler timer0_ovf_isr:17
void timer0_ovf_isr(void)
{
i++;
if (i == 100)
{i=0;
  PORTA= PORTA + 1;}
  TCNT0 = 0x01;
//reload counter value
}
//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
timer0_init();
TIMSK= 0x01; //timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
void main(void)
{
init_devices();
while(1);
}




大家幫忙看看程序有沒有問題,下載到板子,不工作!





歡迎光臨 (http://m.raoushi.com/bbs/) Powered by Discuz! X3.1