if(++Time_Count != 50) return;中的return怎么理解?
/***************writer:shopping.w******************/#include<reg52.h>#defineuintunsig...
/*************** writer:shopping.w ******************/
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit RED_A = P0^0;
sbit YELLOW_A = P0^1;
sbit GREEN_A = P0^2;
sbit RED_B = P0^3;
sbit YELLOW_B = P0^4;
sbit GREEN_B = P0^5;
uchar Time_Count = 0,Flash_Count = 0,Operation_Type = 1;
void T0_INT() interrupt 1
{
TMOD = 0x01;
IE = 0x82;
TR0 = 1;
TH0 = (60000-50000)/256;
TL0 = (60000-50000)%256;
switch(Operation_Type)
{
case 1:
RED_A=0;YELLOW_A=0;GREEN_A=1;
RED_B=1;YELLOW_B=0;GREEN_B=0;
if(++Time_Count != 50) return;
Time_Count=0;
Operation_Type = 2;
break;
case 2:
if(++Time_Count != 8) return;
Time_Count=0;
YELLOW_A=!YELLOW_A;
GREEN_A=0;
if(++Flash_Count != 10) return;//黄灯闪烁5次
Flash_Count=0;
Operation_Type = 3;
break;
case 3:
RED_A=1;YELLOW_A=0;GREEN_A=0;
RED_B=0;YELLOW_B=0;GREEN_B=1;
if(++Time_Count != 20) return;
Time_Count=0;
Operation_Type = 4;
break;
case 4:
if(++Time_Count != 8) return;
Time_Count=0;
YELLOW_B=!YELLOW_B;
GREEN_B=0;
if(++Flash_Count !=10)
return;
Flash_Count=0;
Operation_Type = 1;
break;
}
}
void main()
{
TMOD = 0x01;
IE = 0x82;
TR0 = 1;
TH0 = (60000-50000)/256;
TL0 = (60000-50000)%256;
RED_A=0;YELLOW_A=0;GREEN_A=1;
RED_B=1;YELLOW_B=0;GREEN_B=0;
while(1);
} 展开
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit RED_A = P0^0;
sbit YELLOW_A = P0^1;
sbit GREEN_A = P0^2;
sbit RED_B = P0^3;
sbit YELLOW_B = P0^4;
sbit GREEN_B = P0^5;
uchar Time_Count = 0,Flash_Count = 0,Operation_Type = 1;
void T0_INT() interrupt 1
{
TMOD = 0x01;
IE = 0x82;
TR0 = 1;
TH0 = (60000-50000)/256;
TL0 = (60000-50000)%256;
switch(Operation_Type)
{
case 1:
RED_A=0;YELLOW_A=0;GREEN_A=1;
RED_B=1;YELLOW_B=0;GREEN_B=0;
if(++Time_Count != 50) return;
Time_Count=0;
Operation_Type = 2;
break;
case 2:
if(++Time_Count != 8) return;
Time_Count=0;
YELLOW_A=!YELLOW_A;
GREEN_A=0;
if(++Flash_Count != 10) return;//黄灯闪烁5次
Flash_Count=0;
Operation_Type = 3;
break;
case 3:
RED_A=1;YELLOW_A=0;GREEN_A=0;
RED_B=0;YELLOW_B=0;GREEN_B=1;
if(++Time_Count != 20) return;
Time_Count=0;
Operation_Type = 4;
break;
case 4:
if(++Time_Count != 8) return;
Time_Count=0;
YELLOW_B=!YELLOW_B;
GREEN_B=0;
if(++Flash_Count !=10)
return;
Flash_Count=0;
Operation_Type = 1;
break;
}
}
void main()
{
TMOD = 0x01;
IE = 0x82;
TR0 = 1;
TH0 = (60000-50000)/256;
TL0 = (60000-50000)%256;
RED_A=0;YELLOW_A=0;GREEN_A=1;
RED_B=1;YELLOW_B=0;GREEN_B=0;
while(1);
} 展开
5个回答
展开全部
if(++Time_Count != 50) return;
ruturn指的是返回以下这个循环体:
void T0_INT() interrupt 1
{
TMOD = 0x01;
IE = 0x82;
TR0 = 1;
TH0 = (60000-50000)/256;
TL0 = (60000-50000)%256;
switch(Operation_Type)
{
ruturn指的是返回以下这个循环体:
void T0_INT() interrupt 1
{
TMOD = 0x01;
IE = 0x82;
TR0 = 1;
TH0 = (60000-50000)/256;
TL0 = (60000-50000)%256;
switch(Operation_Type)
{
追问
case 2:
if(++Time_Count != 8) return;
Time_Count=0;
YELLOW_A=!YELLOW_A;
GREEN_A=0;
if(++Flash_Count != 10) return;//黄灯闪烁5次
Flash_Count=0;
这段程序怎么理解呢?大神求详解,你现在的解答我已经明白了许多了,整段好像我还是不是很理解,麻烦了哦
展开全部
Time_Count是一个计数器,当Time_Count += 1后,判断Time_Count是否为50,如果不等,就退出函数T0_INT(),直到调用T0_INT()函数使Time_Count加1后是50了,该函数才得以运行下面代码。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
如果Time_Count增1计数不到50的话,就退出函数返回到主调函数!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
条件语句,若等于五十则顺序执行,若不等于五十则返回主函数,然后到中断,一直循环判断
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
return 是函数运行返回值,执行return后, return 下面的语句是不执行的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询