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

swatch function

hey ..
which library needs to be included when we are using the swatch(float secs) function ??
thanks
pruthvi

Parents
  • Hmm...
    delay...
    There are many different delays:

    1. do nothing:
    {
    unsigned count = NUMBER_OF_TIKS;
    while(--count ){;}
    }

    2. only wait for event, for example using timer0 ( timer and interrupts must be configured)

    unsigned char count ;
    static void timer0_isr (void) interrupt 1
    {
    .....
    if(count)count--;
    }
    void func(){
    ....
    count = NUMBER_OF_TIKS;
    while (count){;}
    ...
    }

    3. wait and do something else
    unsigned char count ;
    bit then_continue;
    static void timer0_isr (void) interrupt 1
    {
    .....
    if(count)count--;
    }
    void one(void){
    count= NUMBER_OF_TIKS;
    then_continue=1;
    }
    void two(void){
    if (!then_continue ) return;
    if (count) return;
    .... // delay finished!
    }

    void main(void)
    {
    count =0; then_continue =0;
    while (1)
    {
    ....
    if( .... ) one(); // start delay
    two();
    .....//

    }
    }

Reply
  • Hmm...
    delay...
    There are many different delays:

    1. do nothing:
    {
    unsigned count = NUMBER_OF_TIKS;
    while(--count ){;}
    }

    2. only wait for event, for example using timer0 ( timer and interrupts must be configured)

    unsigned char count ;
    static void timer0_isr (void) interrupt 1
    {
    .....
    if(count)count--;
    }
    void func(){
    ....
    count = NUMBER_OF_TIKS;
    while (count){;}
    ...
    }

    3. wait and do something else
    unsigned char count ;
    bit then_continue;
    static void timer0_isr (void) interrupt 1
    {
    .....
    if(count)count--;
    }
    void one(void){
    count= NUMBER_OF_TIKS;
    then_continue=1;
    }
    void two(void){
    if (!then_continue ) return;
    if (count) return;
    .... // delay finished!
    }

    void main(void)
    {
    count =0; then_continue =0;
    while (1)
    {
    ....
    if( .... ) one(); // start delay
    two();
    .....//

    }
    }

Children
No data