Thread: flag condition

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    43

    flag condition

    I need to turn on and off some leds with the rising edge and falling edge of the clock,
    i am not exactly sure how to do this but setting flags and having it switch...here is what i have

    BOOL Flag=0; // initializes my flag equal to 0

    if (flag)
    led1 on
    led 2 off;
    flag=0
    else
    led 1 off
    led 2 on
    flag=0






    // generate an interrupt and have the flag set to 1
    flag=1;

    this doesn't work and i am not sure why

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    if( flag )
    {
        ...do flag on stuff...
        flag = 0;
    }
    else
    {
        ...do flag off stuff...
        flag = 1;
    }
    You need to wrap things in braces, if you want them to be clustered as the same block of stuff to do.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mutex, Cond and Thread questions (pthread, linux)
    By thebearot in forum C Programming
    Replies: 14
    Last Post: 04-23-2010, 12:10 PM
  2. Multithreading (flag stopping a thread, ring buffer) volatile
    By ShwangShwing in forum C Programming
    Replies: 3
    Last Post: 05-19-2009, 07:27 AM
  3. can some one please tell me the cause of the error ?
    By broli86 in forum C Programming
    Replies: 8
    Last Post: 06-26-2008, 08:36 PM
  4. need help on error handling.
    By broli86 in forum C Programming
    Replies: 9
    Last Post: 06-19-2008, 11:55 AM
  5. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM