[AVR单片机] 为啥pb3没有输出,设计是1k输出

[复制链接]
1515|2
 楼主| chuandaoxy 发表于 2012-9-29 11:40 | 显示全部楼层 |阅读模式
#include <iom32v.h>
#include <macros.h>
void port_init(void)
{
PORTA = 0x00;
DDRA  = 0x00;
PORTB = 0x08;
DDRB  = 0x08;
PORTC = 0x00;
DDRC  = 0x00;
PORTD = 0x00;
DDRD  = 0x00;
}
//TIMER0 initialize - prescale:64
// WGM: Normal
// desired value: 1KHz
// actual value:  1.002KHz (0.2%)
void timer0_init(void)
{
TCCR0 = 0x00; //stop
TCNT0 = 0x8D; //set count
OCR0  = 0x73;  //set compare
TCCR0 = 0x23; //start timer
}
#pragma interrupt_handler timer0_comp_isr:10
timer0_comp_isr()
{
}

#pragma interrupt_handler timer0_ovf_isr:12
timer0_ovf_isr()
{
TCNT0 = 0x8D;
}
//call this routine to initialize all peripherals
main()
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
timer0_init();
MCUCR = 0x00;
GICR  = 0x00;
TIMSK = 0x03; //timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
dqyubsh 发表于 2012-9-30 01:16 | 显示全部楼层
没有循环,,,
NE5532 发表于 2012-10-1 18:43 | 显示全部楼层
这楼主强,main里不带循环
您需要登录后才可以回帖 登录 | 注册

本版积分规则

856

主题

1046

帖子

4

粉丝
快速回复 在线客服 返回列表 返回顶部