4577 views|14 replies

123

Posts

0

Resources
The OP

Ask questions (reward 10 core coins), [Copy link]

void alarm(void)
{
Add a sentence
if(carry_count*250+pulse_count>=alarm_l)
Alarm=0; //Statements to be skipped

if(carry_count*250+pulse_count<alarm_h)
Alarm=1; //Statement to be executed
}

I want to check before execution if Alarm=0; then skip if(carry_count*250+pulse_count>=alarm_l)
Alarm=0; directly execute the following statement,



This post is from 51mcu

Latest reply

void alarm(void) {   if((carry_count*250+pulse_count>=alarm_l)&&(Alarm != 0))   Alarm=0;   if(carry_count*250+pulse_count  Details Published on 2012-7-24 14:26

60

Posts

0

Resources
2
void alarm(void) { if(Alarm==0) goto LABEL; if(carry_count*250+pulse_count>=alarm_l) Alarm=0;//Statement LABEL to be skipped: if(carry_count*250+pulse_count
Build target 'Target 1' assembling STARTUP.A51... compiling chengxu.c... CHENGXU.C(218): error C202: 'LABEL': undefined identifier CHENGXU.C(221): error C233: 'LABEL': undefined label Target not created
void alarm(void)
{
if(Alarm==0)
goto LABEL;

(A)if(carry_count*250+pulse_count>=alarm_l)
Alarm=0;

LABEL:
(B)if(carry_count*250+pulse_count<alarm_h)
Alarm=1;
}

If Alarm=0, jump to (B), otherwise execute (A). I tried it, but it doesn't work.
void alarm(void) { switch(alarm) case(1):if(carry_count*250+pulse_count>=alarm_l) Alarm=0; //Statements to be skipped case(0):if(carry_count*250+pulse_count
This should be simple. First check whether Alarm is waiting for 1. If it is, all statements are executed. If it is not waiting for 1 (that is, waiting for 0), only if (carry_count*250+pulse_count) is executed.=alarm_l) Alarm=0; //Statements to be skipped} if(carry_count*250+pulse_count
I'm confused. None of them work.
void alarm(void) { if(Alarm!=0) { add a sentence if(carry_count*250+pulse_count>=alarm_l) Alarm=0;//statements to be skipped}else { if(carry_count*250+pulse_count
void alarm(void) { add a sentence if(carry_count*250+pulse_count>=alarm_l) Alarm=0; // statement to be skipped if(carry_count*250+pulse_count=alarm_l) Alarm=0; This sentence directly executes the following statement,
void alarm(void) { switch(Alarm){ case(0):break; case(1): if(carry_count*250+pulse_count>=alarm_l) Alarm=0;//Statements to be skipped if(carry_count*250+pulse_count Alarm=1;//Statements to be executed break; default; } }
goto is definitely OK, I suspect your logic has been optimized by the compiler. Don't worry about it, as long as the result is correct.
void alarm(void) { if(Alarm!=0) { if(carry_count*250+pulse_count>=alarm_l) Alarm=0;//Statements to be skipped} else { if(carry_count*250+pulse_count
There are many ways to write programs, and many of them are written according to your requirements. However, what I want to know is why do you do this? I think this problem can be solved by itself after a period of time, and by that time you will find that these problems today are nothing, or you will wonder why I wrote it this way in the first place?
void alarm(void) { if((carry_count*250+pulse_count>=alarm_l)&&(Alarm != 0)) Alarm=0; if(carry_count*250+pulse_count
void alarm(void) { if((carry_count*250+pulse_count>=alarm_l)&&(Alarm != 0)) Alarm=0; if(carry_count*250+pulse_count
Ask questions (reward 10 core coins),
This post is from 51mcu

123

Posts

0

Resources
3
Build target 'Target 1'
assembling STARTUP.A51...
compiling chengxu.c...
CHENGXU.C(218): error C202: 'LABEL': undefined identifier
CHENGXU.C(221): error C233: 'LABEL': undefined label
Target not created
This post is from 51mcu

123

Posts

0

Resources
4
void alarm(void)
{
if(Alarm==0)
goto LABEL;

(A)if(carry_count*250+pulse_count>=alarm_l)
Alarm=0;

LABEL:
(B)if(carry_count*250+pulse_count<alarm_h)
Alarm=1;
}

If Alarm=0, jump to (B), otherwise execute (A). I tried it, but it doesn't work.
This post is from 51mcu

2423

Posts

19

Resources
5
void alarm(void) { switch(alarm) case(1):if(carry_count*250+pulse_count>=alarm_l) Alarm=0; //Statements to be skipped case(0):if(carry_count*250+pulse_count
This should be simple. First check whether Alarm is waiting for 1. If it is, all statements are executed. If it is not waiting for 1 (that is, waiting for 0), only if (carry_count*250+pulse_count) is executed.=alarm_l) Alarm=0; //Statements to be skipped} if(carry_count*250+pulse_count
I'm confused. None of them work.

void alarm(void) { if(Alarm!=0) { add a sentence if(carry_count*250+pulse_count>=alarm_l) Alarm=0;//statements to be skipped}else { if(carry_count*250+pulse_count
void alarm(void) { add a sentence if(carry_count*250+pulse_count>=alarm_l) Alarm=0; // statement to be skipped if(carry_count*250+pulse_count=alarm_l) Alarm=0; This sentence directly executes the following statement,

void alarm(void) { switch(Alarm){ case(0):break; case(1): if(carry_count*250+pulse_count>=alarm_l) Alarm=0;//Statements to be skipped if(carry_count*250+pulse_count Alarm=1;//Statements to be executed break; default; } }

goto is definitely OK, I suspect your logic has been optimized by the compiler. Don't worry about it, as long as the result is correct.

void alarm(void) { if(Alarm!=0) { if(carry_count*250+pulse_count>=alarm_l) Alarm=0;//Statements to be skipped} else { if(carry_count*250+pulse_count
There are many ways to write programs, and many of them are written according to your requirements. However, what I want to know is why do you do this? I think this problem can be solved by itself after a period of time, and by that time you will find that these problems today are nothing, or you will wonder why I wrote it this way in the first place?

void alarm(void)
{
  if((carry_count*250+pulse_count>=alarm_l)&&(Alarm != 0))
  Alarm=0;

  if(carry_count*250+pulse_count
void alarm(void)
{
  if((carry_count*250+pulse_count>=alarm_l)&&(Alarm != 0))
  Alarm=0;

  if(carry_count*250+pulse_count
Ask questions (reward 10 core coins),


This post is from 51mcu

9

Posts

0

Resources
6
This should be simple. First check whether Alarm is waiting for 1. If it is, all statements are executed. If it is not waiting for 1 (that is, waiting for 0), only if (carry_count*250+pulse_count) is executed.=alarm_l) Alarm=0; //Statements to be skipped} if(carry_count*250+pulse_count
I'm confused. None of them work.

void alarm(void) { if(Alarm!=0) { add a sentence if(carry_count*250+pulse_count>=alarm_l) Alarm=0;//statements to be skipped}else { if(carry_count*250+pulse_count
void alarm(void) { add a sentence if(carry_count*250+pulse_count>=alarm_l) Alarm=0; // statement to be skipped if(carry_count*250+pulse_count=alarm_l) Alarm=0; This sentence directly executes the following statement,

void alarm(void) { switch(Alarm){ case(0):break; case(1): if(carry_count*250+pulse_count>=alarm_l) Alarm=0;//Statements to be skipped if(carry_count*250+pulse_count Alarm=1;//Statements to be executed break; default; } }

goto is definitely OK, I suspect your logic has been optimized by the compiler. Don't worry about it, as long as the result is correct.

void alarm(void) { if(Alarm!=0) { if(carry_count*250+pulse_count>=alarm_l) Alarm=0;//Statements to be skipped} else { if(carry_count*250+pulse_count
There are many ways to write programs, and many of them are written according to your requirements. However, what I want to know is why do you do this? I think this problem can be solved by itself after a period of time, and by that time you will find that these problems today are nothing, or you will wonder why I wrote it this way in the first place?

void alarm(void)
{
  if((carry_count*250+pulse_count>=alarm_l)&&(Alarm != 0))
  Alarm=0;

  if(carry_count*250+pulse_count
void alarm(void)
{
  if((carry_count*250+pulse_count>=alarm_l)&&(Alarm != 0))
  Alarm=0;

  if(carry_count*250+pulse_count
Ask questions (reward 10 core coins),


This post is from 51mcu

123

Posts

0

Resources
7
I'm confused. None of them work.
This post is from 51mcu

115

Posts

0

Resources
8
void alarm(void) { if(Alarm!=0) { add a sentence if(carry_count*250+pulse_count>=alarm_l) Alarm=0;//statements to be skipped}else { if(carry_count*250+pulse_count
void alarm(void) { add a sentence if(carry_count*250+pulse_count>=alarm_l) Alarm=0; // statement to be skipped if(carry_count*250+pulse_count=alarm_l) Alarm=0; This sentence directly executes the following statement,

void alarm(void) { switch(Alarm){ case(0):break; case(1): if(carry_count*250+pulse_count>=alarm_l) Alarm=0;//Statements to be skipped if(carry_count*250+pulse_count Alarm=1;//Statements to be executed break; default; } }

goto is definitely OK, I suspect your logic has been optimized by the compiler. Don't worry about it, as long as the result is correct.

void alarm(void) { if(Alarm!=0) { if(carry_count*250+pulse_count>=alarm_l) Alarm=0;//Statements to be skipped} else { if(carry_count*250+pulse_count
There are many ways to write programs, and many of them are written according to your requirements. However, what I want to know is why do you do this? I think this problem can be solved by itself after a period of time, and by that time you will find that these problems today are nothing, or you will wonder why I wrote it this way in the first place?

void alarm(void)
{
  if((carry_count*250+pulse_count>=alarm_l)&&(Alarm != 0))
  Alarm=0;

  if(carry_count*250+pulse_count
void alarm(void)
{
  if((carry_count*250+pulse_count>=alarm_l)&&(Alarm != 0))
  Alarm=0;

  if(carry_count*250+pulse_count
Ask questions (reward 10 core coins),


This post is from 51mcu

123

Posts

0

Resources
9
void alarm(void) { add a sentence if(carry_count*250+pulse_count>=alarm_l) Alarm=0; // statement to be skipped if(carry_count*250+pulse_count=alarm_l) Alarm=0; This sentence directly executes the following statement,
This post is from 51mcu

2423

Posts

19

Resources
10
void alarm(void) { switch(Alarm){ case(0):break; case(1): if(carry_count*250+pulse_count>=alarm_l) Alarm=0;//Statements to be skipped if(carry_count*250+pulse_count Alarm=1;//Statements to be executed break; default; } }
This post is from 51mcu

4002

Posts

0

Resources
11
goto is definitely OK, I suspect your logic has been optimized by the compiler. Don't worry about it, as long as the result is correct.
This post is from 51mcu

21

Posts

0

Resources
12
void alarm(void) { if(Alarm!=0) { if(carry_count*250+pulse_count>=alarm_l) Alarm=0;//Statements to be skipped} else { if(carry_count*250+pulse_count
There are many ways to write programs, and many of them are written according to your requirements. However, what I want to know is why do you do this? I think this problem can be solved by itself after a period of time, and by that time you will find that these problems today are nothing, or you will wonder why I wrote it this way in the first place?

void alarm(void)
{
  if((carry_count*250+pulse_count>=alarm_l)&&(Alarm != 0))
  Alarm=0;

  if(carry_count*250+pulse_count
void alarm(void)
{
  if((carry_count*250+pulse_count>=alarm_l)&&(Alarm != 0))
  Alarm=0;

  if(carry_count*250+pulse_count
Ask questions (reward 10 core coins),


This post is from 51mcu

223

Posts

0

Resources
13
There are many ways to write programs, and many of them are written according to your requirements. However, what I want to know is why do you do this? I think this problem can be solved by itself after a period of time, and by that time you will find that these problems today are nothing, or you will wonder why I wrote it this way in the first place?
This post is from 51mcu

11

Posts

0

Resources
14
void alarm(void)
{
  if((carry_count*250+pulse_count>=alarm_l)&&(Alarm != 0))
  Alarm=0;

  if(carry_count*250+pulse_count
void alarm(void)
{
  if((carry_count*250+pulse_count>=alarm_l)&&(Alarm != 0))
  Alarm=0;

  if(carry_count*250+pulse_count
Ask questions (reward 10 core coins),


This post is from 51mcu

11

Posts

0

Resources
15
void alarm(void)
{
  if((carry_count*250+pulse_count>=alarm_l)&&(Alarm != 0))
  Alarm=0;

  if(carry_count*250+pulse_count
Ask questions (reward 10 core coins),


This post is from 51mcu

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>

    EEWorld
    subscription
    account

    EEWorld
    service
    account

    Automotive
    development
    circle

    Robot
    development
    community

    Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
    快速回复 返回顶部 Return list