This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

If statement do not work (?) Newbie Question

Dear friends,

I am writing a small code for an 89LPC935 and KEIL uVision3 + MCB900 board, and all goes good untill i try to enter the If .. else statement :((

Take a look and give me some tip if available >>>

If (Keyb_input == 0x0B); // Keyboard "Play" press
    {
        Debug++;         // Increment Debug register
        P2 = Debug;      // Debug keypad press to Port2
                                }

Notes:
(*) The Keyb_input is declared at the begining of the program as unsigned char data Keyb_input

(*) Error messages are >> missing function prototype requires ANSI-style prototype

Parents
  • My dearest friend,

    You should also look at the code relating to 'counter_us'.

    1 - It should be volatile, since it is being sampled repeatedly by your Delay_20ms function and is being updated by an ISR. The optimizer (probably) will do things that I suspect you currently do not consider.

    2 - In the same vein, the variable is a 16 bit integer; i.e., stored in two bytes (on an 8051) so while the delay loop is half way through accessing it, the ISR may come in and changing the value.

    You might get your code to compile, but without considering these points, you might find the operation isn't always as you intend; i.e., buggy.

    Kindest regards,

    Happy Happening.

Reply
  • My dearest friend,

    You should also look at the code relating to 'counter_us'.

    1 - It should be volatile, since it is being sampled repeatedly by your Delay_20ms function and is being updated by an ISR. The optimizer (probably) will do things that I suspect you currently do not consider.

    2 - In the same vein, the variable is a 16 bit integer; i.e., stored in two bytes (on an 8051) so while the delay loop is half way through accessing it, the ISR may come in and changing the value.

    You might get your code to compile, but without considering these points, you might find the operation isn't always as you intend; i.e., buggy.

    Kindest regards,

    Happy Happening.

Children
No data