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

a new digital clock

hi ,

i want to build a new digital clock with a procesor and need your knowlege.

what procesor would work for it????? would arm be quik enough????

can i use a 32,768 hz watch crystal???? but would it make it slow??????

all help will be kind.

(chief programmer zuisti)

Parents
  • OK - here is some of the relevant parts of Oberon-07 code used in the digital clock:

    The that module that reads the time from the LPC2148 is:

    
    MODULE Clock;
    
    IMPORT LPC, SYSTEM;
    
    CONST
      PCLK = 16000000;
    
    PROCEDURE* GetTime*(VAR hh, mm, ss: INTEGER);
    BEGIN
      SYSTEM.GET(LPC.SEC, ss);
      SYSTEM.GET(LPC.MIN, mm);
      SYSTEM.GET(LPC.HOUR, hh);
    END GetTime;
    
    
    PROCEDURE* Seconds*(): INTEGER;
    VAR
      ss: INTEGER;
    BEGIN
      SYSTEM.GET(LPC.SEC, ss);
      RETURN ss
    END Seconds;
    
    
    PROCEDURE* Init*();
    VAR
      preint, prefrac: INTEGER;
    BEGIN
      preint := (PCLK DIV 32768) - 1;
      prefrac := PCLK - ((preint + 1) * 32768);
      SYSTEM.PUT(LPC.PREINT, preint);
      SYSTEM.PUT(LPC.PREFRAC, prefrac);
      SYSTEM.PUT(LPC.CCR, {0});
    END Init;
    
    END Clock.
    

    The main part of the module that then formats the time and displays it on the LCD is:

    
    PROCEDURE DisplayTime();
    VAR
      hh, mm, ss: INTEGER;
      s: String;
    BEGIN
      Clock.GetTime(hh, mm, ss);
      Clear(s);
      AddInt(s, hh);
      AddChar(s, ':');
      AddInt(s, mm);
      AddChar(s, ':');
      AddInt(s, ss);
      LCD.SetCursor(1, 0);
      LCD.String(s.chars);
    END DisplayTime;
    
    PROCEDURE Run();
    VAR
      prevSecs, secs: INTEGER;
      i: INTEGER;
      sel2: SET;
    BEGIN
      SYSTEM.PUT(LPC.PINSEL0, 0);
      SYSTEM.PUT(LPC.PINSEL1, 0);
      SYSTEM.GET(LPC214x.PINSEL2, sel2);
      SYSTEM.PUT(LPC214x.PINSEL2, sel2 * {2, 3});
    
      LCD.Init(LCD.Linesx2, LCD.DisplayOn, LCD.Increment);
      LCD.ClearDisplay();
      LCD.String("ARM Oberon-07");
      Clock.Init();
      prevSecs := 0;
      WHILE TRUE DO
        secs := Clock.Seconds();
        IF secs # prevSecs THEN
          DisplayTime();
          prevSecs := secs
        END
      END
    END Run;
    

    (For some unknown reason Some of the lines were clipped in the preview - I hope they appear OK in the final post)

    Regards,
    Chris

Reply
  • OK - here is some of the relevant parts of Oberon-07 code used in the digital clock:

    The that module that reads the time from the LPC2148 is:

    
    MODULE Clock;
    
    IMPORT LPC, SYSTEM;
    
    CONST
      PCLK = 16000000;
    
    PROCEDURE* GetTime*(VAR hh, mm, ss: INTEGER);
    BEGIN
      SYSTEM.GET(LPC.SEC, ss);
      SYSTEM.GET(LPC.MIN, mm);
      SYSTEM.GET(LPC.HOUR, hh);
    END GetTime;
    
    
    PROCEDURE* Seconds*(): INTEGER;
    VAR
      ss: INTEGER;
    BEGIN
      SYSTEM.GET(LPC.SEC, ss);
      RETURN ss
    END Seconds;
    
    
    PROCEDURE* Init*();
    VAR
      preint, prefrac: INTEGER;
    BEGIN
      preint := (PCLK DIV 32768) - 1;
      prefrac := PCLK - ((preint + 1) * 32768);
      SYSTEM.PUT(LPC.PREINT, preint);
      SYSTEM.PUT(LPC.PREFRAC, prefrac);
      SYSTEM.PUT(LPC.CCR, {0});
    END Init;
    
    END Clock.
    

    The main part of the module that then formats the time and displays it on the LCD is:

    
    PROCEDURE DisplayTime();
    VAR
      hh, mm, ss: INTEGER;
      s: String;
    BEGIN
      Clock.GetTime(hh, mm, ss);
      Clear(s);
      AddInt(s, hh);
      AddChar(s, ':');
      AddInt(s, mm);
      AddChar(s, ':');
      AddInt(s, ss);
      LCD.SetCursor(1, 0);
      LCD.String(s.chars);
    END DisplayTime;
    
    PROCEDURE Run();
    VAR
      prevSecs, secs: INTEGER;
      i: INTEGER;
      sel2: SET;
    BEGIN
      SYSTEM.PUT(LPC.PINSEL0, 0);
      SYSTEM.PUT(LPC.PINSEL1, 0);
      SYSTEM.GET(LPC214x.PINSEL2, sel2);
      SYSTEM.PUT(LPC214x.PINSEL2, sel2 * {2, 3});
    
      LCD.Init(LCD.Linesx2, LCD.DisplayOn, LCD.Increment);
      LCD.ClearDisplay();
      LCD.String("ARM Oberon-07");
      Clock.Init();
      prevSecs := 0;
      WHILE TRUE DO
        secs := Clock.Seconds();
        IF secs # prevSecs THEN
          DisplayTime();
          prevSecs := secs
        END
      END
    END Run;
    

    (For some unknown reason Some of the lines were clipped in the preview - I hope they appear OK in the final post)

    Regards,
    Chris

Children