No.33124 作者:fengsunping 邮件:fengzhijie-2001@163.com ID:103427 登陆:1次 文章数:1篇 最后登陆IP:121.229.161.165 最后登陆:2008/3/6 11:08:52 注册:2008/3/6 11:01:55 财富:105 发帖时间:2008/3/6 11:08:52 发贴者IP:121.229.161.165 标题:fengsunping:AVR定时问题[求助] 摘要:No.33124AVR定时问题[求助] //ICC-AVR application builder : 2008-3-6 9:46:31 // Target : M16 // Crystal: 6.0000Mhz #include <iom16v.h> #include <macros.h> void port_init(void) { PORTA = 0xff; DDRA = 0xff; PORTB = 0x00; DDRB = 0x00; PORTC = 0x00; //m103 output only DDRC = 0x00; PORTD = 0x00; DDRD = 0x00; } //TIMER0 initialize - prescale:256 // WGM: CTC // desired value: 10mSec // actual value: 10.027mSec (-0.3%) void timer0_init(void) { TCCR0 = 0x00; //stop //TCNT0 = 0x16; //set count OCR0 = 0xEA; //set compare TCCR0 = 0x0C; //start timer } #pragma interrupt_handler timer0_comp_isr:20 void timer0_comp_isr(void) { static unsigned char i,count1s; coun ......
>>返回讨论的主题
|