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

  • swatch is simulator<\b>, not C51, function!

    Start debug session, type
    DIR FUNC
    in the debuger command line- list of predefined functions

  • hi ..
    then how do we use in our c programs for generating some delay ..
    can u sight some examples of this swatch() ??
    regards
    pruthvi

  • The uVision Debug Functions are described in the uVision Getting Started Guide - you need to read it!

    For creating software delays, do a 'Search' on this forum.

  • 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();
    .....//

    }
    }