Watch

SQ003116E006
ML610Q400 Series
Sample Program AP Notes
For
Watch Application
2nd Edition
Issue Date: April 16, 2010
NOTICE
No copying or reproduction of this document, in part or in whole, is permitted without the consent of LAPIS
Semiconductor Co., Ltd.
The content specified herein is subject to change for improvement without notice.
The content specified herein is for the purpose of introducing LAPIS Semiconductor's products (hereinafter
"Products"). If you wish to use any such Product, please be sure to refer to the specifications, which can be obtained
from LAPIS Semiconductor upon request.
Examples of application circuits, circuit constants and any other information contained herein illustrate the standard
usage and operations of the Products. The peripheral conditions must be taken into account when designing circuits
for mass production.
Great care was taken in ensuring the accuracy of the information specified in this document. However, should you
incur any damage arising from any inaccuracy or misprint of such information, LAPIS Semiconductor shall bear no
responsibility for such damage.
The technical information specified herein is intended only to show the typical functions of and examples of
application circuits for the Products. LAPIS Semiconductor does not grant you, explicitly or implicitly, any license
to use or exercise intellectual property or other rights held by LAPIS Semiconductor and other parties. LAPIS
Semiconductor shall bear no responsibility whatsoever for any dispute arising from the use of such technical
information.
The Products specified in this document are intended to be used with general-use electronic equipment or devices
(such as audio visual equipment, office-automation equipment, communication devices, electronic appliances and
amusement devices).
The Products specified in this document are not designed to be radiation tolerant.
While LAPIS Semiconductor always makes efforts to enhance the quality and reliability of its Products, a Product
may fail or malfunction for a variety of reasons.
Please be sure to implement in your equipment using the Products safety measures to guard against the possibility of
physical injury, fire or any other damage caused in the event of the failure of any Product, such as derating,
redundancy, fire control and fail-safe designs. LAPIS Semiconductor shall bear no responsibility whatsoever for
your use of any Product outside of the prescribed scope or not in accordance with the instruction manual.
The Products are not designed or manufactured to be used with any equipment, device or system which requires an
extremely high level of reliability the failure or malfunction of which may result in a direct threat to human life or
create a risk of human injury (such as a medical instrument, transportation equipment, aerospace machinery,
nuclear-reactor controller, fuel-controller or other safety device). LAPIS Semiconductor shall bear no responsibility
in any way for use of any of the Products for the above special purposes. If a Product is intended to be used for any
such special purpose, please contact a ROHM sales representative before purchasing.
If you intend to export or ship overseas any Product or technology specified herein that may be controlled under the
Foreign Exchange and the Foreign Trade Law, you will be required to obtain a license or permit under the Law.
Copyright 2009 - 2011 LAPIS Semiconductor Co., Ltd.
Table of Contents
1.
OVERVIEW ............................................................................................................................................................. 1
2.
SYSTEM CONFIGURATION ................................................................................................................................ 2
2.1.
2.2.
2.3.
2.4.
2.5.
2.6.
2.7.
3.
DESCRIPTION OF FUNCTIONAL MODULES ............................................................................................... 10
3.1.
4.
HARDWARE CONFIGURATION .............................................................................................................................. 2
PERIPHERAL CIRCUIT DIAGRAM ......................................................................................................................... 3
LCD PANEL SPECIFICATIONS .............................................................................................................................. 4
SOFTWARE CONFIGURATION ............................................................................................................................... 5
LIST OF FOLDERS AND FILES ............................................................................................................................... 6
BUILD PROCEDURE ............................................................................................................................................. 7
RESTRICTIONS .................................................................................................................................................... 8
RTC MODULE ................................................................................................................................................... 10
DESCRIPTION OF THE SAMPLE PROGRAM ............................................................................................... 20
4.1.
4.2.
4.3.
4.4.
4.5.
4.6.
4.7.
FUNCTIONS OF SAMPLE PROGRAM ................................................................................................................. 20
COMMON SPECIFICATIONS .............................................................................................................................. 20
CONFIGURATION OF THE LCD PANEL ............................................................................................................... 21
KEY EVENT ....................................................................................................................................................... 22
STATE TRANSITION DIAGRAM ........................................................................................................................... 23
STATE TRANSITION TABLE ................................................................................................................................ 23
DESCRIPTION OF MODE ..................................................................................................................................... 24
i
1.
Overview
This document describes the application programming notes (hereafter called the AP notes) arranged to help customers
develop software that performs time measurements and a setting on the ML610Q400 Series MCU (hereafter called the
MCU).
APIs are provided for each function module. The AP notes describe the functions and operating conditions of each API
and samples of use of those APIs.
In connection with the AP notes, a sample program is provided that actually operates using APIs on ML610Q400 Series
Demo Kit.
Related Documents
The following are the related documents. Read them as required.
ML610Q400 Series Sample Program AP Notes For Sensor/Mesurement Application
ML610Q400 Series Sample Program API Manual
ML610Q431/ML610Q432 User’s Manual
ML610Q411/ML610Q412/ML610Q415 User’s Manual
ML610Q421/ML610Q422 User’s Manual
ML610Q435/ML610Q436 User’s Manual
ML610Q400 Series Demo kit Hardware User’s Manual
nX-U8/100 Core Instruction Manual
MACU8 Assembler Package User’s Manual
CCU8 User’s Manual
CCU8 Programming Guide
CCU8 Language Reference
DTU8 User’s Manual
IDEU8 User’s Manual
uEASE User’s Manual
uEASE Connection Manual ML610Qxxx
FWuEASE Flash Writer Host Program User’s Manual
LCD Image Tool User’s Manual
1
2.
System Configuration
2.1.
Hardware Configuration
The following figure shows the hardware configuration on which the sample software runs.
LCD
Power Supply
PWR
SW
Internal
lithium coin
battery
External
power
supply input
terminal
Internal /
External
Select SW
ML610Q4xx
reference board
RS232C
Thermistor
IF
Humidity sensor
BUZZER
SSIO
IF
1st/2nd/3rd
function
Select SW
I2C
EEPROM
RS232C
IF
Control switch
P0/NMI/RESET
ML610Q400 Series Demo Board
Figure 2-1
Hardware Configuration
In the above hardware configuration, the peripheral parts which are necessary for running the sample software are
shown below.
Peripheral parts
Control switch
The number of
peripheral parts
4
LCD panel
1
Descriptions
The switch S1, S2, S3 and S4 are used to change mode or control the
application.
It displays the mode and a display of time of operation.
2
2.2.
Peripheral Circuit Diagram
LCD
Coin Cell
NMI
VDD
COM0~3 (*)
SEG0~63 (*)
NMI
S1
S2
P00/CAP0
EXVDDV
P01/CAP1
EXGND
P02
S3
P03
S4
RESET_N
ML610Q4xx
P30/IN0
P31/CS0
CX
Cd
Cc
Cb
Ca
VDDX
P32/RS0
VL4
P33/RT0
VL3
P34/RCT0
VL2
P35/RCM
VL1
P44/IN1
C4
P45/CS1
C34
P46/RS1
C3
C2
1/4 Bias
P47/RT1
CS0
CVR0
RS0
RT0
CS1
CVR1
RS1
RT1
C12
C1
XT0
CGL
AVDD
AVref
XL
CDL
AVSS
XT1
32.768KHz
Xtal
P22
/MD0
P20 P41 P40
P42 P43
/RXD /TXD
AIN0
(Output) /SCL /SDA
Buzzer
ICL2332
GND R1In T1Out
4
3
V+
2
GND TXD RXD
V-
WP SCL SDA
9-pin D-SUB
A0 A1
CV
:1uF
:1uF
CL0
CL1
:0.1uF
:1uF
C1
CX
:0.1uF
Ca,Cb,Cc,Cd
:1uF
:1uF
C12,C34
: No ( 0 pF )
CGL
CDL
: No ( 0 pF )
Vcc
2
I C EEPROM
A2
Vss
RS0
CS0
CVR0
RT0
: 10 Kohm
: 560 pF
: 820 pF
: 103AT (Semitec) thermister
RS1
CS1
CVR1
RT1
: 150 Kohm
: 680 pF
: 820 pF
: C10-M53R (Shinyei) humidity sensor
(*) The number of COM/SEG pin that can be connected to LCD panel depends on the type of the LCD driver built into
the MCU. Please see the chapter “LCD Driver” of the User’s Manual for your target MCU.
For more detail about the peripheral curcuit, please see the “ML610Q400 Series Demo Kit Hardware User’s Manual”.
3
2.3.
LCD Panel Specifications
16-segment characters:
7-segment characters:
8-segment characters:
Marks for hand-held calculator:
Other marks:
Figure 2-2
The 4 digits on the upper part of the panel
The 6 digits on the upper part of the panel
The 12 digits on the lower part of the panel
7
32
Layout of the LCD Panel
Table 2-1 Pin Assignments (COM/SEG)
Specifications of Operation
Clock for bias generation circuit voltage multiplication:
Bias of the bias generation circuit:
Duty:
Frame frequency:
4
1/16 LSCLK (2 kHz)
1/4
1/4 duty
73 Hz
2.4.
Software Configuration
Figure 1-1 shows the software configuration.
Figure 2-3
Software Configuration
5
2.5.
List of Folders and Files
The folders and the files are as listed below.
[watch]
├ [_output]
│ ├ [_hex]
│ ├ [_lst]
│ ├ [_obj]
│ └ [_prn]
├ [clock]
│ ├ clock.c
│ ├ clock.h
│ ├ clock_sysFunc.c
│ └ clock_sysFunc.h
├ [irq]
│ ├ irq.c
│ └ irq.h
├ [key]
│ ├ key.c
│ ├ key.h
├ [lcd]
│ ├ LCD.c
│ ├ LCD.h
│ ├ U8_Sample.tac
│ └ U8_Sample.tbc
├ [main]
│ ├ mcu_large
│ │ └ mcu.h
│ ├ mcu_small
│ │ └ mcu.h
│ ├ eepromMap.h
│ ├ main.BAK
│ ├ main.c
│ ├ main.h
│ ├ S610431SW.asm
│ └ S610435LW.asm
├ [rtc]
│ ├ rtc.c
│ └ rtc.h
├ [t1k]
│ ├ t1k.c
│ └ t1k.h
├ [tbc]
│ ├ tbc.c
│ └ tbc.h
├ [timer]
│ ├ timer.c
│ └ timer.h
├ readme.txt
├ U8_watch_Sample_Large.PID
└ U8_watch_Sample_Small.PID
… Build result output folder
… Clock control module folder
… Interrupt control module folder
… Key input control module folder
… LCD display control module folder
… Sample program main folder
…Real time clock module folder
… 1 kHz timer control module folder
… Time base counter control module folder
… Timer control module folder
… Description of compile options
… Project file for large model MCU
… Project file for samll model MCU
6
2.6.
Build Procedure
1 Start IDEU8, select the menu “Open” and open the project file (PID file). In the case that MCU memory model is
small model, the project file is “U8_watch_Sample_Small.PID”. In the case of large model, the project file is
“U8_watch_Sample_Large.PID”. Correspondence of MCU and PID file is shown below.
Table 2-2 Correspondence of MCU and PID file
Supported MCU
U8_watch_Sample_Small.PID
ML610Q431/432
ML610Q421/422
ML610Q411/412/415
U8_watch_Sample_Large.PID
ML610Q435/436
2 In the default setting, ML610Q431 is set as the target MCU.
If your target MCU is different, follow the procedure below to change the setting.
(1) Select the menu “Project” -> “Options” -> “Compiler/assembler”.
(2) In the displayed window, select the target MCU from the “Target microcontroller” list in the “General”
tab.
(3) Remove the startup file “S610431SW.asm“ registered in the file tree of IDEU8. Instead of that, register
your target MCU’s startup file. (In the case of ML610Q432, it is S610432SW.asm.)
(4) Define the macro that represents the target MCU.
Select the menu “Project” -> “Options” -> “Compiler/assembler” -> ”Macro”tab. In the displayed
window, define the macro like following name.
_ML610Q4XX
About the “XX” part, replace with the type number of MCU
For example, if ML610Q432 is used, define the following macro.
_ML610Q432
In the case that the macro other than the type number in the above Table 2-2 is defined, the case that
macro such as above is not defined, or the case that the memory model that is supported by PID file is
different from the memory model of MCU that is defined by the above macro, the compiler issues the
following error at the beginning of the output messages.
Error : E2000 : #error : “Unknown target MCU”
(5) If necessary, modify other macro definitions.
About the available macro definitions, see the “readme.txt” in the sample program folder.
- For ML610Q43X series MCU
LCD_TYPE = 1
_RTC_TYPE or _SOFTWARE_RTC
- For ML610Q42X series MCU
LCD_TYPE = 1
_SOFTWARE_RTC
- For ML610Q41X series MCU
LCD_TYPE = 0
_SOFTWARE_RTC
3 Select the menu “Project” -> “Rebuild”. Then the build procssing for the sample program starts.
4 When the build processing is completed, .abs file is generated in the project folder and .hex file is generated in
_output¥_hex folder.
7
2.7.
Restrictions
2.7.1.
About Available Functional Modules
In the functional modules that compose this sample program, the available functional modules are different by target
MCU, due to the difference of MCU peripherals. In the case that these functional modules are applied to user
application, available functional modules on each MCU are shown below.
Table 2-3 List of available functional modules
Supported MCU
LCD Display Control Module *2
Key Input Control Module *2
Functional
modules
RTC Control
Module
Hardware RTC
Software RTC
Timer Control Module *2
Clock Control Module *2
1 kHz Timer Control Module *2
Time Base Counter Control Module *2
ML610Q43X ML610Q42X ML610Q41X ML610Q48X
○
○ *1
○ *1
×
○
○
○
○
○
×
×
×
○
○
○
○
○
○
○
○
○
○
○
○
○
○
○
×
○
○
○
○
○ : Available
× : Not available
*1: All display area of LCD panel can not be available, because the number of SEG pin that is connected to LCD panel
is not enough.
*2: For the details of these modules, please see the “ML610Q400 Series Sample Program AP Notes For
Sensor/Mesurement Application”.
2.7.2.
About Functions of Sample Program
This sample program is available on only ML610Q43X, ML610Q42X and ML610Q41X series MCU.
Note: This sample program is not available on ML610Q48X series MCU, because it does not have LCD driver, which
are required for operating the application.
8
2.7.3.
About Display Area of LCD panel
The display area of LCD panel is different by each MCU as follows, because of the specification difference of LCD
driver.
* It is requred for displaying all areas of LCD panel that LCD driver supports 64seg×4com pins at least. The number of
COM/SEG pin that LCD driver in each MCU supports is listed in parenthesis.
ML610Q43X: All area can be displayed.
(ML610Q431: 64seg×16com, ML610Q432: 64seg×24com)
ML610Q42X: Only the area of 1, 2 and 4 can be displayed.
(ML610Q421: 50seg×8com, ML610Q422: 50seg×16com)
ML610Q41X: Only the area of 1 and 2 can be displayed.
(ML610Q411: 36seg×4com, ML610Q412: 44seg×4com, ML610Q415: 36seg×4com)
ML610Q48X: All area can not be displayed, because ML610Q48X does not have LCD driver.
9
3.
Description of Functional Modules
3.1.
RTC Module
This sample program provides two methods to realize the real time clock (RTC). One method is the hardware RTC and
another is the software RTC. The hardware RTC is enabled by default. The software RTC is enabled when the macro
“_SOFTWARE_RTC” is defined. The software RTC can realize the RTC function even if MCU doesn’t have the RTC
function.
About MCU that has the real time clock (RTC) function
The following shows the configuration of the RTC in MCU.
Data bus
Control circuit
RTCCON
Alarm 0/1
Control circuit
RTCINT
(Periodic interrupt)
Periodic interrupt control
0.5 sec
T2HZ
T1HZ
Operation
control
1 sec
AL0INT, AL1INT
(Alarm interrupt)
1 min.
Day counter
WEEK,
DAY, MON, YAER
Time counter
SEC, MIN, HOUR
Data bus
RTCCON: Real time clock control register
* For details, refer to the chapter “Real Time Clock” of the User’s Manual for your target MCU.
10
About MCU that does not have the real time clock (RTC) function
The RTC function is realized by the software RTC. The following shows the functional block diagram of the software
RTC.
About the detail of each function, please see the secton “3.1.1 Function Overview”.
Application
Set time
rtc_setTime function
Current time data
Get time
rtc_getTime function
Set Alarm 0/Alarm 1
rtc_setAlarm0/rtc_setAlarm
1 function
Alarm 0/Alarm 1 setting
data
Get the setting of
Alarm 0/Alarm 1
rtc_getAlarm0/rtc_getAlarm
1 function
Update time
rtc_updateTime function
Count date and time
Alarm control
Alarm 0 callback
Alarm 1 callback
Alarm 0
Application processing
Alarm 1
Application processing
11
3.1.1.
Function Overview
The RTC module mainly sets the settings for the counting functions of the real time clock of the MCU.
Table 3-20 lists the RTC module APIs that the sample program uses.
Table 3-1 List of APIs
Function name
rtc_setTime function
rtc_getTime function
rtc_start function
rtc_stop function
rtc_setRegularInt function
rtc_setAlarm0 function
rtc_setAlarm1 function
rtc_getAlarm0 function
rtc_getAlarm1 function
rtc_updateTime function
rtc_calcWeekday function
Hardware
RTC
Description
Sets date (year, month, day, day of the
week) and clock time (hour, minute,
second).
Obtains date (year, month, day, day of the
week) and clock time (hour, minute,
second).
Starts RTC operation.
Stops RTC operation.
(*2)
(*2)
Selects the interval between periodic
interrupts.
Sets Alarm 0(day of the week, hour,
minute).
Sets Alarm 1(month, day, hour, minute).
Obtains the setting of Alarm 0(day of the
week, hour, minute).
Obtains the setting of Alarm 1(month, day,
hour, minute).
Updates date (year, month, day, day of the
week) and clock time (hour, minute,
second).
Calculates day of the week.
Software
RTC
(*2)
(*1)
(*1) Not available for the hardware RTC.
(*2) No need to use for the software RTC. These functions do not execute any processing in the software RTC.
12
3.1.2.
Operating Conditions
This section describes the operating conditions and valid range of this module. It also describes the restrictions on this
module.
The RTC is stopped immediately after an MCU reset.
Year values settable with the date counting function
Month values settable with the date counting function
Day values settable with the date counting function
Day of the week values settable with the date counting function
Hour values settable with the clock time counting function
Minute values settable with the clock time counting function
Second values settable with the clock time counting function
Year range in which day of the week can be calculated
00–99
01–12
01–31
1–7
00–23
00–59
00–59
2000–2099
Note:
The parameters used in each of the APIs above must be specified by binary-code decimal (BCD) values, except for
day of the week.
Day of the week, which is calculated by rtc_calcWeekday function, is represented by the following values.
day of the week
value
Sunday
1
Monday
2
Tuesday
3
Wednesday
4
Thursday
5
Friday
6
Saturday
7
The timing that the alarm occurs is different between the hardware RTC and the software RTC.
¾ Hardware RTC:
Alarm interrupt (AL0INT、AL1INT)
¾ Software RTC:
Main routine (rtc_updateTime function call)
13
3.1.3.
Sample of Use
The subsection below describes the procedure for setting date and clock time using RTC module.
3.1.3.1. Date and Clock Time Setting Procedure (Hardware RTC)
The figure below shows the procedure for setting date (year, month, day, day of the week) and clock time (hour, minute,
second) using the hardware RTC function in RTC module.
Main Routine
1)
Stop RTC operation
rtc_stop function
2)
Set date and clock time in RTC
rtc_setTime function
3)
Start RTC operation
rtc_start function
4)
Obtain date and clock time of RTC
rtc_getTime function
Figure 3-1
Date and Clock Time Setting Procedure (Hardware RTC)
14
[Main Routine]
1) Stop RTC operation (because date and clock time have to be set with the RTC stopped)
2) Set date and clock time
¾ Stop RTC operation using the rtc_stop function.
¾ Set date and clock time using the rtc_setTime function.
1 Second data (0–59)
2 Minute data (0–59)
3 Hour data (0–23)
4 Day-of-the-week data (1–7)
5 Day data (1–31)
6 Month data (1–12)
7 Year data (0–99)
*By resetting the low-speed time base counter, clear the internal counter used to count for less than one second.
3) Start RTC operation
¾ Start RTC operation using the rtc_start function.
4) Obtain the date and clock time of RTC
¾ Obtain the current date (year, month, day, day of the week) and clock time (hour, minute, second) using the
rtc_getTime function.
15
3.1.3.2. Date and Clock Time Setting Procedure (Software RTC)
The figure below shows the procedure for setting date (year, month, day, day of the week) and clock time (hour, minute,
second) using the software RTC function in RTC module.
Main Routine
Figure 3-2
1)
Calculate day of the week
rtc_calcWeekday function
2)
Set date and clock time
rtc_setTime function
3)
Update date and clock time
rtc_updateTime function
4)
Obtain date and clock time of RTC
rtc_getTime function
Date and Clock Time Setting Procedure (Software RTC)
16
[Main Routine]
1) Calculate day of the week
¾ Calculate day of the week using the rtc_calcWeekday function.
2) Set date and clock time
¾ Set date and clock time using the rtc_setTime function.
1 Second data (0–59)
2 Minute data (0–59)
3 Hour data (0–23)
4 Day-of-the-week data (caluculated value by rtc_calcWeekday function)
5 Day data (1–31)
6 Month data (1–12)
7 Year data (0–99)
3) Update date and clock time
¾ Update the current date (year, month, day, day of the week) and clock time (hour, minute, second) by calling
rtc_updateTime function at regular intervals (every second).
4) Obtain the date and clock time of RTC
¾ Obtain the current date (year, month, day, day of the week) and clock time (hour, minute, second) using the
rtc_getTime function.
17
3.1.3.3. Alarm 0 Setting Procedure (Software RTC)
The figure below shows the procedure for setting alarm 0 using the software RTC function in RTC module.
Main Routine
1)
Set alarm 0
rtc_setAlarm0 function
Update date and clock time
rtc_updateTime function
2)
When the current time reaches
the time of alarm 0,
callback function is executed
3)
Obtain the alarm 0 setting
rtc_getAlarm0 function
Figure 3-3
Alarm 0 callback processing
(callback function)
Alarm 0 Setting Procedure (Software RTC)
[Main Routine]
1) Set alarm 0
¾ Set date and clock time using the rtc_setAlarm0 function.
1 Minute data (0–59)
2 Hour data (0–23)
3 Day-of-the-week data (1–7)
4 Address of callback function
¾ If you do not use the day-of-the-week data as comparison data of alarm 0, set “0x00” as its data. For example, in
the case of setting 8:30 in the morning to alarm 0, set “0x00” to the day-of-the-week data, then set “8(hour)” and
“30(minute)” to the hour and minute data respectively.
2) Update date and clock time
¾ Update the current date and clock time by calling rtc_updateTime function.
¾ If the current time reaches the time that is set to alarm 0 (day of the week, hour, minute) when the second of
current time overflows (from 59 to 00) and the minute is raised up, the callback function specified in above “Set
alarm 0 (rtc_setAlarm0 function)” is executed.
3) Obtain the alarm 0 setting
¾ Obtain the current alarm 0 setting data (day of the week, hour, minute, address of callback function) using the
rtc_getAlarm0 function.
18
3.1.3.4. Alarm 1 Setting Procedure (Software RTC)
The figure below shows the procedure for setting alarm 1 using the software RTC function in RTC module.
Main Routine
1)
Set alarm 1
rtc_setAlarm1 function
Update date and clock time
rtc_updateTime function
2)
When the current time reaches
the time of alarm 1,
callback function is executed
3)
Obtain the alarm 1 setting
rtc_getAlarm1 function
Figure 3-4
Alarm 1 callback processing
(callback function)
Alarm 1 Setting Procedure (Software RTC)
[Main Routine]
1) Set alarm 1
¾ Set date and clock time using the rtc_setAlarm1 function.
1 Minute data (0–59)
2 Hour data (0–23)
3 Month data (1–12)
4 Day data (1–31)
5 Address of callback function
¾ If you do not use the month and day data as comparison data of alarm 1, set “0x00” as its data. For example, in
the case of setting 8:30 in the morning to alarm 1, set “0x00” to the month and day data, then set “8(hour)” and
“30(minute)” to the hour and minute data respectively.
2) Update date and clock time
¾ Update the current date and clock time by calling rtc_updateTime function.
¾ If the current time reaches the time that is set to alarm 1 (month, day, hour, minute) when the second of current
time overflows (from 59 to 00) and the minute is raised up, the callback function specified in above “Set alarm 1
(rtc_setAlarm1 function)” is executed.
3) Obtain the alarm 1 setting
¾ Obtain the current alarm 1 setting data (month, day, hour, minute, address of callback function) using the
rtc_getAlarm1 function.
19
4.
Description of the Sample Program
The following shows the functional specification of the sample program.
4.1.
Functions of Sample Program
The sample program offers three functions shown below.
Function
Time display
Calendar setup
Time setup
4.2.
Function outline
The present time (hour, minute and second) and a calendar (date and day of the week) are
displayed.
Operation duty and contrast are adjusted by key operation.
Date is set up by key operation.
Calendar (year, month and day) is set up by key operation.
The place during setup blinks.
Also during a calendar setup, time is updated and the newest time is displayed on LCD.
Time is set up by key operation.
Set up time (hour and minute) by key operation.
The place during setup blinks.
Also during a time setup, time is updated and the newest time is displayed on LCD.
Common Specifications
1) System clock
• SYSCLK=LSCLK (32 kHz)
2) Timer
• Base time (1s) creation
Software RTC: 1 kHz timer, operating clock LSCLK, 1Hz mode
Hardware RTC: RTC 1 second interrupts.
•
Operation duty creation
Timer0, 1(16bit mode), operating clock LSCLK, overflow interval: It is dependent on a setup of duty of
operation (refer the table below).
* It is not used when the operation duty is set to 100%
3) LCD driver
• Bias voltage multiplying clock: 2 kHz, bias : 1/4 bias, 1/4 duty
• Frame frequency: 73 Hz
4) MCU operation duty
• 10~100%, in units of 10%.
Duty ratio(%)
Opereation time(ms)
HALT time(ms)
10
100
900
20
200
800
30
300
700
40
400
600
50
500
500
60
600
400
70
700
300
80
800
200
90
900
100
100
const
-
20
4.3.
Configuration of the LCD Panel
The following subsections describe the LCD panel configuration and types of display.
The LCD panel has two types of display patterns depending on the type of the LCD driver built into the MCU: one with
the display allocation function and the other without it.This sample explains as the display allocation function.
4.3.1.
LCD Display Image with Display Allocation Function
The display allocation function is available if DSPMOD1’s DASN (bit 2) can be set to “1”.
The display image in this case is shown below.
Day of the week
Operation
duty
3
T H U
Clock time
2 3
2 0 0 9
Day of the week
Clock time
Year
Month and day
5 9
:
5 9
1 2 3 1
Year
Name
Operation duty
:
Month and day
Content to be displayed
The mark of "1" - "10" on either side shows the sample program operation duty.
Duty ratio 10% : “1”
Duty ratio 20% : “2”
:
Duty ratio 100% : “10”
The day of the week applicable to the present date is displayed in left justified format.
Sunday: SUN
Monday: MON
Tuesday: TUE
Wednesday: WED
Thursday: THU
Friday: FRI
Saturday: SAT
Displays the current time in 24 hour format.
Displays current year. Upper place of year is fixed to “20”.
Displays current month and day.
21
4.4.
Key Event
The key event that the sample program handles is only a short-press release.
Short-press release: Polling is performed at 128-Hz intervals from the time a key was pressed, and a short-press release
is confirmed if a match occurs four times but the key is released in less than 2 seconds.
Priority:
Key S1 > Key S2 > Key S3 > Key S4
22
4.5.
State Transition Diagram
Power-on
Reset by RESET_N pin
or
reset by WDT overflow
Initialization
Short S1 press
Short S1 press
Short S2 press
Short S2 press
Calendar setup mode
Short S4 press
Time display mode
Short S3 press
Short S3 press
Short S4 press
Short S2 press
Time setup mode
Short S4 press
Short S3 press
Short S1 press
Figure 4-1
4.6.
State transition diagram(Whole)
State Transition Table
Mode
S1
State
Short S1 press
Time
display
Calendar
setup
Time setup
Key
S2
Short S2
press
S3
Short S3
press
Normal
[State change]
Shifts to Duty adjustment state
-
-
Duty
adjustment
[State change]
Shifts to Contrast adjustment
state
Parameter
UP
Parameter
Down
Contrast
adjustment
[State change]
Shifts to Normal state
Parameter
UP
Parameter
Down
[Setting (blink) place change]
Shifts to place of “Month”
[Setting (blink) place change]
Shifts to place of “Day”
[Setting (blink) place change]
Shifts to place of “Year”
[Setting (blink) place change]
Shifts to place of “Minute”
[Setting (blink) place change]
Shifts to place of “Second”
[Setting (blink) place change]
Shifts to place of “Hour”
Parameter
UP
Parameter
UP
Parameter
UP
Parameter
UP
Parameter
UP
Parameter
UP
Parameter
Down
Parameter
Down
Parameter
Down
Parameter
Down
Parameter
Down
Parameter
Down
Setting place
“Year”
Setting place
“Month”
Setting place
“Day”
Setting place
“Hour”
Setting place
“Minute”
Setting place
“Second”
:
:
:
:
:
:
23
S4
Short S4 press
[Mode change]
Shifts to Calendar setup
mode
[Mode change]
Shifts to Time setup
mode
[Mode change]
Shifts to Time display
mode
4.7.
Description of mode
Mode
Time display mode
Calendar setup mode
Time setup mode
Description
Renewal of time is performed for every second using RTC (software/hardware) function, and
the present time and a date are displayed.
Moreover, duty of operation or LCD contrast of MCU is changed by key operation.
Calendar (year, month, day) is set up by key operation.
* Day of the week is calculated by the sample software side.
Time (hour, minute, second reset) is set up by key operation.
24
4.7.1.
Time display mode
Change of a display of time, duty of operation, and LCD contrast is performed.
4.7.1.1.
¾
¾
¾
¾
¾
¾
Description of operation
Date, Time and the mark of the operation duty are displayed after clearing LCD display.
The operation duty of MCU and contrast are changed by the key input.
The initial value of calendar time is 0:0 0 second on January 1, 2000.
The initial value of the operation duty is 100%.
The initial value of the contrast of LCD is 8.
LCD is switched off when key operation is not performed during 1 minute. (Normal state only)
4.7.1.2. Description of screen
There are three kinds of states, a time display, duty adjustment, and contrast adjustment, in the time display mode.
And there is a screen corresponding to each state (state is changed by short S1 press).
1.
Time display mode (usually) screen
Day of the week
Operation
duty
3
T H U
Clock time
2 3
2 0 0 9
Name
Operation duty
Day of the week
Clock time display
Year
Month and day
5 9
:
5 9
1 2 3 1
Year
Figure 4-2
:
Month and day
Time display mode (usually)
Content to be displayed
Mark of "1" - "10" on either side shows the sample program operation duty.
Duty ratio 10% : “1”
Duty ratio 20% : “2”
:
Duty ratio 100% : “10”
The day-of-the-week applicable to the present date is displayed in left justified format..
Sunday: SUN
Monday: MON
Tuesday: TUE
Wednesday: WED
Thursday: THU
Friday: FRI
Saturday: SAT
Displays the current time in 24 hour format.
Displays current year. Upper place of year is fixed to “20”.
Displays current month and day.
25
2. Time display mode (duty adjustment) screen
Operation
duty
Mode display
Clock time
D U T Y
2 3
:
5 9
:
5 9
4
Figure 4-3
Name
Operation duty
Time display mode (duty adjustment)
Content to be displayed
The mark of "1" - "10" on either side shows the sample program operation duty.
Duty ratio 10% : “1”
Duty ratio 20% : “2”
:
Duty ratio 100% : “10”
Mode
Clock time
"DUTY" is displayed.
Displays the current time in 24 hour format.
3. Time display mode (contrast adiustment) screen
Operation
duty
Mode display
C O N T
Clock time
2 3
:
5 9
:
5 9
4
1 F
Contrast display
Figure 4-4
Name
Operation duty
Time display mode (contrast adjustment)
Content to be displayed
The mark of "1" - "10" on either side shows the sample program operation duty.
Duty ratio 10%
Duty ratio 20%
:
Duty ratio 100%
Mode display
Clock time display
Contrast display
: “1”
: “2”
: “10”
"CONT" is displayed.
Displays the current time in 24 hour format.
The contrast (value of a contrast register) of LCD is displayed.
26
4.7.1.3. Description of key operation
Key event uses only short press. Long press of key is no effect.
1. Time display mode (usually) screen
When one of keys is pushed during LCD putting out lights, LCD lighting is performed but operation of a key is not
performed.
Key
Operation
S1
Short press
Shifts to duty adjustment state.
S2
Short press
No effect.
S3
Short press
No effect.
S4
Short press
Shifts to calendar setup mode.
2. Time display mode (duty adiustment) screen
Key
Operation
S1
Short press
Shifts to contrast adjustment state.
The operation duty of MCU is adjusted.
S2
Short press
Whenever it pushes once, duty ratio is added 10%.
When duty ratio is 100%, it sets up to 10%.
The operation duty of MCU is adjusted.
S3
Short press
Whenever it pushes once, duty ratio is subtracted 10%.
When duty ratio is 10%, it sets up to 100%.
S4
Short press
Shifts to calendar setup mode.
3. Time display mode (Contrast adiustment) screen
Key
Operation
S1
Short press
Shifts to normal state.
Contrast of LCD is adjusted.
S2
Short press
Whenever it pushes once, contrast is added 1.
When contrast is maximum (*), it is set as 0. * Maximum value varies in MCU.
Contrast of LCD is adjusted.
S3
Short press
Whenever it pushes once, contrast is subtracted 1.
When contrast is maximum (*), it is set as 0. * Maximum value varies in MCU.
S4
Short press
Shifts to calendar setup mode.
27
4.7.2.
Calendar setup mode
Calendar (year, month, day) is set up.
4.7.2.1. Description of operation
¾ Date is displayed after clearing LCD display.
¾ Renewal of time is performed also during edit.
But renewal of the date place by the carry from the time place is not performed.
(edit: 2009/12/31 23:59:59 ´ 2009/12/31 00:00:00)
¾ The blinking place is moved in the order of the year -> month -> day -> year … by the key input.
(Blink cycle: 1 Hz)
¾ The present date is edited.
4.7.2.2.
Description of screen
2 0 0 9
1 2 3 1
Year display
Figure 4-5
Month and day
Calendar setup mode
Name
Content to be displayed
Year display
Displays current year. Upper place of year is fixed to “20”.
Month and day
Displays current month and day.
* The place during setup blinks.
4.7.2.3.
Description of key operation
Key
Short
press
Operation
The place of date which is set up (blinking place) is changed (in the order of year -> month -> day).
S1
If it goes around, it will return to the place of year.
The count rise of the place during setup is carried out.
In the case of maximum value, it returns to the minimum value.
Short
The range of a count rise:
S2
press
Year
00~99
Month 01~12
Day
01~31
The countdown of the place during setup is carried out.
In the case of the minimum value, it returns to maximum value.
Short
The range of a countdown:
S3
press
Year
00~99
Month 01~12
Day
01~31
It shifts to the time setup mode after calendar decision.
Short
*When date setting value is unexpected date (when February 30 is set up etc), date is reset to 1st
S4
press
date of the next month.
*A day of the week is calculated using date that has been set.
*Long press of key is no effect.
28
4.7.2.4. Validation of date input
In this sample software, the validity of user input value is judged in the following procedure, and unexpected input
value is corrected.
1) Setup of a date
¾ Date (year, month, date) is set up using S1, S2, and S3 key.
2) S4 key input
¾ When S4 key is inputted, the day-of-the-week set up with the rtc_calcWeekday function is calculated.
3) Success or failure of a day-of-the-week calculation result
¾ When the setting value of day is more than the final day (28~31) of month, it judges as an unexpected input
with an rtc_calcWeekday function. (A leap year is also taken into consideration.)
¾ When it succeeds in day-of-the-week calculation with an rtc_calcuWeekday function, the setting value of date
is accepted.
¾ When it fails in day-of-the-week calculation with an rtc_calcuWeekday function, it judges with an error and
the following date compensation is performed.
1 Advance the place of the "month" for one month.
2 The place of a "day" will be set up on "the 1st."
3 Perform day-of-the-week calculation again.
[Example]
¾
Though it is not a leap year, date is set up to February 29.
1 Date Input by User.
2 0 0 9
0 2 2 9
Month and day
Year
2
S4 key input (to time setup mode).
Day of the week
Clock time
S U N
:
2 0 0 9
0 0
:
0 0
3
Year
Month and day
29
1
¾
When a date is set up on November 31.
1 Date input by User.
2 0 0 9
1 1 3 1
Year
2
Month and day
S4 key input (to time setup mode).
Day of the week
Clock time
T U E
:
0 0
:
0 0
2 0 0 9
1 2
Year
Month and day
30
1
4.7.3.
Time setup mode
Time (hour and minute) is set up.
4.7.3.1. Description of operation
¾ Date is displayed after clearing LCD display.
¾ Renewal of time is performed also during edit.
But renewal of the date place by the carry from a time place is not performed.
(edit: 2009/12/31 23:59:59 ´ 2009/12/31 00:00:00)
¾ The blinking place is moved in the order of hour -> minute -> second -> hour by the key input.
(Blink cycle: 1 Hz)
¾ The present time (hour, minute, second) is edited. The edited contents are immediately set to RTC.
¾ When S2/S3 key is short-pressed during the place of "second" is selected, a second is set as 00.
4.7.3.2.
Description of screen
Day of the week
Clock time
T H U
2 3
5 9
:
2 0 0 9
Name
Day of the week
5 9
1 2 3 1
Year
Figure 4-6
:
Month and day
Time setup mode
Content to be displayed
The day of the week applicable to the present date is displayed in left justified format.
Sunday: SUN
Monday: MON
Tuesday: TUE
Wednesday: WED
Thursday: THU
Friday: FRI
Saturday: SAT
Clock time
Year
Month and day
Displays the current time in 24 hour format.
*The place during setup blinks and is displayed.
Displays current year. Upper place of year is fixed to “20”.
Displays current month and day.
31
4.7.3.3.
Description of key operation
Key
S1
Short
press
S2
Short
press
S3
Short
press
Operation
The place of time which is sets up (blinking place) is changed (in the order of hour -> minute ->
second).
If it goes around, it will return to hour.
The count rise of the place during setup is carried out.
In the case of maximum value, it returns to the minimum value.
The range of a count rise:
Hour
00~23
Minute 00~59
Second 00fix
The countdown of the place during setup is carried out.
In the case of the minimum value, it returns to maximum value.
The range of a countdown:
Hour
00~23
Minute 00~59
Second 00fix
Short
It shifts to the time display mode.
press
*Long press of key is no effect.
S4
32
4.7.4.
Cautions when Using Hardware RTC (About time setting timing)
The time which RTC holds is updated for every count for 1 second by the low-speed time base counter. Moreover, the
event of S2 or S3 key performs processing which updates the time of RTC in this sample program. If the timing by
which the value of RTC is updated overlaps during processing of a time setup by this program, the old time (1 second
before) which the program holds may be set to RTC.In this case, a display of clock time will be delayed for 1 second.
In this sample program, as the measure for the clock time delay at RTC setup, key events are suspended on the
following condition and it is made not to perform RTC setup. The suspended key event is re-set when it returns to the
calendar edit mode or the time edit mode. The key event holds the key event that is occurred latest.
Condition: LTBR (the low-speed time base counter) is more than 0xF0. (RTC interrupt occurs within 62.5ms.)
Usually, although the processing time of a time setup is about 10ms, since key interrupt will occur several
times also during a time setup if a key is hit repeatedly, it takes about 60ms by the maximum. A time setup and
RTC interruption are made not to overlap by preparing the prohibition time of a time setup.
Figure 4-7
Time setup outline flow
33
Revision History
34
Revision History
Page
Edition
Date
2
2010.4.16
Previous
Edition
Current
Edition
–
–
Description
Initial Edition
35