Scoreboard in AT89S8252

Discussion in 'Embedded Systems and Microcontrollers' started by tntgsh, Apr 21, 2009.

  1. tntgsh

    Thread Starter New Member

    Apr 21, 2009
    1
    0
    Hello.
    I'm trying to make a program for a Scoreboard using a AT89S8252 in C, but I'm having some trouble doing the stopwatch, since I'm not familiar to C language and this is my first project.
    The stopwatch would have 4 digits, two for seconds and two for minutes, going from 00:00 to 99:59.
    If someone could give me some directions, or even the structure of the code, I would be able to continue.
    Thanks a lot for the help,
    Tntgsh.
     
  2. Arm_n_Legs

    Active Member

    Mar 7, 2007
    183
    10
    Write a timer interrupt routine to interrupt, say, every 10ms

    //--- Timer Interrupt Routine-----
    // Runs every 10ms
    void timekeeper(void) interrupt 1
    {
    TF0=0; // Reset Interupt Flag​

    TH0=0xb1; // Next overflow in 10ms​
    TL0=0xe0;
    count++;​
    if (count==100){ // 1 sec elapsed.​
    count=0;​
    timeToggle=1;​
    sec++;​
    if (sec==60){​
    sec=0;​
    min++;​
    if (min==60){​
    min=0;​
    hr++;​
    if (hr==24){​
    hr=0;​
    }​
    }​
    }​
    }​
    }
     
Loading...