ST AN841 Application note

AN841

APPLICATION NOTE

A clock design using the ST6-REALIZER

INTRODUCTION

Today Clock systems are used in more and more applications because of the added features they open:

Current Time display, Event dating, process start time programming,...

Generally, this feature is part of a more global system, and cost effective solutions are required.

MCU solutions are more and more often used thanks to the onboard provided Timer and all the possibilities offered by the MCU embedded resources to manage other tasks. This approach allows single chip solutions which brings a great advantage in fields like small home appliances.

A simple time of day clock, provided with an alarm feature, has then been developed as example with the help of the ST6-REALIZER.

June 2008

Rev 2

1/10

A clock design using the ST6-REALIZER

1 APPLICATION OVERVIEW

The clock system provides the following features:

Current time counting

Alarm triggering at a defined time

Current time setup

Alarm time setup

The time values are represented in the HH:MM format, but the described concept can easily be extended to representation in seconds. By using this HH:MM format, the time value is represented by a pair of integer variables ranging in [0..59] for the minutes and [0..23] for the hours.

The user interface consists of 4 keys:TIME SETUP, ALARM SETUP, HOURS and MINUTES.

With these 4 keys, both the current time and the alarm time can be adjusted:

When the key TIME SETUP is activated, the Hours (Resp. Minutes) variable of the current time is increased at each activation of the key HOURS (Resp. MINUTES).

When the key ALARM SETUP is activated, the Hours (Resp. Minutes) variable of the Alarm time is increased at each activation of the key HOURS (Resp. MINUTES).

A decrementation of any of the time variables is achieved by successive incrementations since they are reset when they reach the maximum value (23 for the hours and 59 for the minutes). For instance, passing from 22 Hours to 2 Hours needs 4 steps: 22 > 23 > 0 > 1 > 2.

2/10

ST AN841 Application note

A clock design using the ST6-REALIZER

2 FUNCTIONAL PRINCIPLE

All the featured functions of the clock system are managed on the final application under software control by the MCU. However, using the ST6-REALIZER allows to generate this application software by functional description of the system. Thus the software development can be achieved by a system oriented or hardware like description.

2.1 Current time counting

The system uses a 1 Hz timebase generated with the embedded Timer of the ST62 MCU. This oscillating timebase is used to trigger three chained Modulo-N counters (Unit Counter):

one for the seconds (n = 60)

one for the minutes (n = 60)

one for the hours (n = 24).

When any of these Unit Counter reaches its maximum value, a clock is issued to increment the Unit counter of the next stage.

2.2 Current time setup

The current time value is modified by incrementation of the counters used for the current time counting. This is achieved by duplicating the clock input of the involved counter directly in the current time counting block. Practically, two different additional clocks are needed, one for the minutes incrementation and one for the hours incrementation. Each of these additional clocks is controlled by the combination of the keys, TIME SETUP, HOURS and MINUTES.

2.3 Alarm time setup

A structure very close to the current time setup has been used. Two counters are used, one for the minutes, and one for the hours. Unlike current time counting, the content of these counters can be modified only by pressure on the keys ALARM SETUP, HOURS and MINUTES.

2.4 Alarm triggering

An alarm process is launched when the current time is equal to the alarm predefined time. The occurrence is enabled by a double comparison: Hours equal, Minutes equal.

Figure 1. Application block diagram

 

TIMEBASE

 

 

TIME SETUP

2

Current

2

Hour, Min Setup

 

Time

 

 

 

 

ALARM SETUP

 

Computing

 

USER

 

 

 

 

COMPARISON

HOURS

INTERFACE

 

 

2

2 Hour, Min Alarm Setup

Alarm

 

MINUTES

 

Time

 

 

Setup

 

 

 

 

 

 

 

VR02064A

 

 

 

3/10

Loading...
+ 7 hidden pages