找回密码
 注册会员
更新自动建库工具PCB Footprint Expert 2024.04 Pro / Library Expert 破解版

请教过零同步

[复制链接]
admin 发表于 2012-9-2 21:25:03 | 显示全部楼层 |阅读模式

本文包含原理图、PCB、源代码、封装库、中英文PDF等资源

您需要 登录 才可以下载或查看,没有账号?注册会员

×
请教各位高手,能帮我把这个C程序的过零检测这段程序换成汇编吗,或者给点思路都行,先谢谢了!






//七色渐变(过零检测)
//晶振24MHZ
#include <reg52.h>
#include <stdio.h>
typedef unsigned char uchar;

sbit blue=P1^7;
sbit green=P1^6;
sbit red=P1^5;
sbit int0_tag=P3^2;
uchar zero_tag;
unsigned int time;
void delay_time1(unsigned int m)
{

uchar j;
EA=0;
while(m--)
{
for(j=0; j<10; j++){;}
}
EA=1;
}
void delay_time(unsigned int m)
{
EA=0;
while(m--)
{
;
}
EA=1;
}

void wait(uchar mm)
{
uchar tt;
for(tt=0;tt<mm;tt++)
{
while(!zero_tag);
zero_tag=0;
delay_time1(400);
}
}
//通过对交流过零点检测,实现七色渐变
void initialize()
{
IT0=1;
EX0=1;
EA=1;
}

void main()
{

unsigned int t,w=500;
initialize();
red=green=blue=1;
do
{

for(t=1;t<w;t++) // 由白色渐变红色
{
while(!zero_tag);
zero_tag=0;
red=1;
green=1;
blue=1;
delay_time1(w-t);

red=1;
green=0;
blue=0;
delay_time1(t);
}


for(t=1;t<w;t++) //由红色渐变黄色
{
while(!zero_tag);
zero_tag=0;
red=1;
green=0;
blue=0;
delay_time1(w-t);
red=1;
green=1;
blue=0;
delay_time1(t);
}


for(t=1;t<w;t++) //由黄色渐变绿色
{
while(!zero_tag);
zero_tag=0;
red=1;
green=1;
blue=0;
delay_time1(w-t);
green=1;
red=0;
blue=0;
delay_time1(t);
}


for(t=1;t<w;t++) //由绿色渐变青色
{ while(!zero_tag);
zero_tag=0;
blue=0;
green=1;
red=0;
delay_time1(w-t);
green=1;
blue=1;
red=0;
delay_time1(t);
}


for(t=1;t<w;t++) //由青色渐变兰色
{ while(!zero_tag);
zero_tag=0;
green=1;
blue=1;
red=0;
delay_time1(w-t);
blue=1;
red=0;
green=0;
delay_time1(t);
}



for(t=1;t<w;t++) //由兰色渐变紫色
{
while(!zero_tag);
zero_tag=0;
red=0;
blue=1;
green=0;
delay_time1(w-t);
blue=1;
red=1;
green=0;
delay_time1(t);
}



for(t=1;t<w;t++) //由紫色渐变白色
{ while(!zero_tag);
zero_tag=0;
red=1;
green=0;
blue=1;
delay_time1(w-t);
red=1;
blue=1;
green=1;
delay_time1(t);
}



} while(1);
}

void int0_int(void) interrupt 0
{
delay_time(4);
if(int0_tag==0)
{
zero_tag=1;
time++;
}
else{;}
}
*滑块验证:
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

QQ|手机版|MCU资讯论坛 ( 京ICP备18035221号-2 )|网站地图

GMT+8, 2024-11-29 11:34 , Processed in 0.050523 second(s), 8 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表