2019-07-17 00:40发布
mountfushan 发表于 2012-12-17 13:57 在百度知道上看到过你的提问。你最好说得再详细些,比如脉冲的作用什么的。这样高手才好帮你。新手路过。 ...
最多设置5个标签!
其实这种直接说给原理图的 一般少有人有空给弄的
程序在写完成发过去验证一下 我也不能确定输出一定能让你想要的那种脉冲共同学习
#include<iom16v.h>
#include<macros.h>
#define uchar unsigned char
#define uint unsigned int
void port_init()
{
DDRB=0Xff;
PORTB=0X00; //低电平灯灭
}
void drive_init()
{
MCUCR|=0x03; //上升沿中断触发
GICR|=BIT(6);//使能外部中断
TCCR0=0X02; //8分频
TCNT0=0X37; //定时0.1ms溢出
SREG|=BIT(7);//打开总中断
}
void main(void)
{
port_init();
drive_init();
while(1);
}
#pragma interrupt_handler int0_isr:2
void int0_isr()
{
//send_pwm();
TIMSK|=BIT(TOIE0);
}
#pragma interrupt_handler time0_isr:10
void time0_isr()
{
static uchar countime0;
TCNT0=0X37;
countime0++;
if(countime0>=300)
{
PORTB&=~BIT(0);
}
if(countime0<=90)
{
PORTB|=BIT(0);
}
}
一周热门 更多>