Real Time Clock Microcontroller 12C887 (RTCM12)

OBJECTIVE

  1. Students understand about real time clock
  2. Students understand the RTC interface circuit with a microcontroller
  3. Students understand how to create an RTC data retrieval program

Basic Theory

Real Time Clock is a chip (IC) that has a function as a time indicator. RTC DS 12C887 has a register that can show seconds, minutes, hours, date, month and year. This RTC is designed to have 128 RAM locations consisting of 15 bytes for time data and control, and 113 bytes as RAM that can be used as RAM in general.

The RTC DS 12C887 uses a multiplexed bus to save pins. The timing used to access the RTC can use Intel timing or Motorola timing. This RTC is also equipped with an IRQ pin for ease of processing.

Operation of RTC

The following is a picture of the RTC DS 12C887 pins, the total number of pins is 13:


Figure 14.1 RTC DS 12C887 Pins

The following will show the block diagram of the RTC DALLAS 12C887. It can be seen from the block diagram that the RTC is divided into several main parts with controls and I/O for its operation.

Table 14.1 below explains the function of each pin:

| Nama Pin | Keterangan                            |
|----------|---------------------------------------|
| MOT      | Motorola / Intel timing               |
| AD0-AD7  | Bus DATA / ADDRESS yang termultipleks |
| CS       | Chip Select                           |
| AS       | Address Strobe                        |
| R/W      | Write Strobe                          |
| DS       | Data Strobe                           |
| RESET    | Inputan Reset                         |
| IRQ      | Interrupt Request Output              |
| SQW      | Output Sinyal Kotak                   |
| VCC      | Catu tegangan +5 volt                 |
| Gnd      | Ground                                |
| RCLR     | Hapus RAM                             |

The explanation of each DS12C887 RTC pin is explained below:

1. GND, VCC

It is a pin for the RTC power supply. VCC is given +5 volt input. When the 5 volt voltage is given within normal limits, the RTC is freely accessible and data can be written or read. While when Vcc is below 4.25 volts, the read and write process cannot be done. However, the timing process (timekeeping) is still carried out by the RTC without being affected by the low input voltage. When VCC drops below 3 volts, the power supply for RAM and the timer is transferred to the internal lithium battery found in the RTC. The RTC timer function has an accuracy of ± 1 minute per month at a temperature of 250 C even without a supply to the VCC.

2. MOT (Mode Select) 

The MOT pin provides the freedom to choose two types of buses. When this pin is connected to VCC, the motorolla bus timing is selected, while when it is connected to ground or left (not connected) the intel bus timing is selected. This pin has an internal pull down of about 20 k?.

3. SQW (Square Wave Output) 

The SQW pin can output a square signal, from one to 13 divisions provided by the 15 internal divider stages of the RTC. The frequency of the SQW can be selected by programming register A as shown in the table. The SQW signal can be turned on and off by setting the SQWE bit in register B. The SQW signal is turned off when VCC is below 4.25 volts.

4. AD0 - AD7 (Multiplexed and bidirected Address/Data bus) 

Multiplexed bus saves pin usage because address information and timing data use the same signal path. Address appears in the first part of the bus cycle and the same pin is used for data in the second part of the bus cycle. Multiplexing between data and address does not slow down the access time of the RTC because the change from address to data is done when accessing the internal RAM of the RTC. Address must be valid when the falling edge occurs on AS/ALE, which then the RTC will latch the address from AD0 to AD6. Valid data to be written to the RTC must be valid and kept stable when the DS and WR pins are given a pulse. In the reading process, the RTC produces an 8-bit data output when the DS and RD pins are given a pulse. The bus will become high impedance when a low pulse is given to the DS pin (motorola) or a high pulse is given to the RD pin (intel).

5. AS (Address Strobe Input) 

A positive pulse change in the address strobe is useful for multiplexing the bus. A negative pulse change in the AS will cause the address to latch. A subsequent positive change will clear the address even though the CS is not activated. The access command should be sent simultaneously.

6. DS (Data Strobe or Read Input)

The DS/RD pin has 2 modes of operation depending on the level assigned to the MOT. When the MOT is connected to VCC, the motorola bus timing is selected and in this mode the DS is a positive pulse during the later part of the bus cycle and is called a data strobe. During the reading process, the DS indicates that the RTC has a bidirectional bus. During the writing process, a positive pulse on the DS will latch the data being written. When the MOT is connected to ground, the intel bus timing is selected and the DS pin is called read (RD). RD describes the period when the RTC treats the bus as a data reader. The RD signal has the same meaning as the Output Enable (OE) signal on a common memory.

7. R/W (Read/Write Input)

The R/W pin also has 2 modes of operation. When the MOT pin is connected to VCC for motorola timing, R/W is at a level that indicates whether it is in a read or write process. The read process is indicated by a high level on R/W while DS is also high. The write process is indicated when R/W is low and DS is high. When the MOT pin is connected to ground for intel timing, the R/W signal is an active low signal called WR. In this mode the R/W pin has the same meaning as the Write Enable (WE) signal as in general RAM.

8. CS (Chip Select Input)

The chip select signal must be held low to access the bus cycle. CS must be kept active during DS and AS in Motorola timing or RD and WR in Intel timing. A bus cycle that occurs without CS enabled will latch the address but no access can be made. When VCC is below 4.25 volts, the RTC internally blocks access by internally disabling the CS input. This process protects both the RTC data and the RAM data when there is no power supply.

9. IRQ (Interrupt Request Output)

The IRQ pin is an active low output from the RTC 12C887 which is used as an interrupt input to the processor. The IRQ output remains low as long as the status bit causes the interrupt to occur and the associated interrupt-enable bit is set. To clear an interrupt is usually done by reading the C register. The RESET pin also clears interrupts that have been done or have not occurred (pending). When no interrupt occurs, the IRQ level is in a high impedance condition. Several interrupt devices can be connected to the IRQ bus. The IRQ bus is an open drain output and requires additional pull-up resistors.

10. RESET (Reset Input)

The RESET pin has no effect on the clock, calendar or RAM. When the RTC is turned on, the RESET pin can be kept LOW for a while to stabilize the power supply. The length of time the RESET pin is kept low depends on the application being used. However, if reset is used during power up, the RESET time must be kept low for more than 200 ms to ensure that the RTC's internal timer for power up is sufficient. When RESET is low and VCC is above 4.25 volts, the following things happen:

  1. Periodic Interrupt Enable (PEI) is cleared to zero.
  2. Alarm Interrupt Enable (AIE) is cleared to zero.
  3. Update Ended Interrupt Flag (UF) is cleared to zero.
  4. The Interrupt Request Status Flag (IRQF) is cleared to zero.
  5. Periodic Interrupt Flag (PF) is cleared to zero.
  6. The RTC cannot be accessed until RESET goes high.
  7. The Alarm Interrupt Flag (AF) is cleared to zero.
  8. The IRQ pin is in high impedance condition.
  9. Square Wave Output Enable (SQWE) is cleared to zero.
  10. Update Ended Interrupt Enable (UIE) is cleared to zero.

In general applications, RESET can be connected directly to VCC. This connection will allow the RTC 12C887 to function when there is a power supply failure without affecting the RTC control register.

11. Address Map from RTC

RTC has internal RAM in it, in the memory is divided into several registers that have functions in controlling and retrieving RTC data. In order to avoid errors in controlling and retrieving data, the address map of each register must be clear.

The RTC address map consists of 113 bytes of RAM that can be used by the RTC user, 11 bytes of RAM that contain RTC data such as time, calendar and alarm, and 4 bytes used for control and status. All 128 bytes can be written or read directly except in the following circumstances:

  1. Registers C and D are read-only.
  2. The 7th bit of register A is read-only.
  3. The upper bits of the seconds byte are read-only.


Figure 14.2. RTC Address Map

Time, Calendar and Alarm 

Time and calendar information is obtained by reading the appropriate memory bytes. Time, calendar and alarm are set or initialized by writing to the appropriate RAM bytes. The contents of the ten calendar, time and alarm data can be used in binary or BCD (Binary-Coded Decimal) mode. Before accessing the calendar, time and alarm registers, the SET bit in register B must be written to the appropriate logic level so as not to interfere with the update process carried out by the RTC. All calendar, time and alarm data must use the same data mode (binary or BCD), namely by writing to register B on the DM (Data Mode) bit. Once initialized, the RTC will continue to use the previously selected data mode. The following table shows the data modes of the calendar, time and alarm in both binary and BCD modes.

Table 14.2. Time, calendar and alarm mode data table


Table 14.2. Time, calendar and alarm mode data table

Register Control RTC

The RTC 12C887A has 4 control registers that can be accessed at any time, even when the RTC is performing an update cycle.

Register A

| BIT 7 | BIT 6 | BIT 5 | BIT 4 | BIT 3 | BIT 2 | BIT 1 | BIT 0 |
|-------|-------|-------|-------|-------|-------|-------|-------|
| UIP   | DV2   | DV1   | DV0   | RS3   | RS2   | RS1   | RS0   |

UIP -- Update in progress is a monitorable bit status, is a read only bit and is not affected by reset. When the UIP bit is 1, the update process will take place immediately. When the UIP is 0, the update process will not occur for at least 244?s. Calendar, time and alarm information in RAM will be fully accessible when the UIP bit is zero.

DV2, DV1, DV0 -- These three bits are used to turn the oscillator on or off and reset the calculation chain. The 010 pattern is the only combination that will turn the oscillator on and cause the RTC to keep time. The 11x pattern will turn the oscillator on but hold the calculation chain in the reset state.

RS2, RS2, RS1, RS0 -- These four bits will select the frequency or turn off the square pulse on the SQW pin. The SQW pin can also function as a periodic interrupt. These four bits can be read/written and are not affected by RESET. To activate them, you can do the following:

  1. Enable interrupts with the PIE bit.
  2. Enable SQW output with the SQWE bit.
  3. Activate both at the same time and frequency.
  4. Do not enable either.

Register B

| BIT 7 | BIT 6 | BIT 5 | BIT 4 | BIT 3 | BIT 2 | BIT 1 | BIT 0 |
|-------|-------|-------|-------|-------|-------|-------|-------|
| SET   | PIE   | AIE   | UIE   | SQWE  | DM    | 24/12 | DSE   |

SET -- When the SET bit is 0, the update process functions normally by adding calculations once a second. When SET is written to 1, all update processes are stopped so that the program can initialize the time and calendar bytes without any updates occurring in the middle of the initialization process.

PIE -- Periodic Interrupt Enable is a read/write bit that causes the Periodic Interrupt Flag (PF) bit in register C to set the IRQ pin low. When the PIE bit is set to 1, periodic interrupts are generated by setting the IRQ pin low for a period of time according to the RS3-RS0 bits (register A). When PIE is set to 0, this prevents the IRQ pin from being set by periodic interrupts, but the PF bit is still set to a period of time. PIE cannot be changed internally by the RTC, but is cleared to 0 on RESET.

UIE -- Update Ended Interrupt is a read/write bit that will enable the Update ended Flag (UF) in register C to insert an IRQ. A "low" RESET pin or a "high" SET bit will clear the UIE bit.

SQWE -- When the Square Wave Enable bit is set to 1, a square wave with the period specified by the RS3-RS0 bits is output on the SQW pin. When SQWE is set to 0, the SQW pin remains low. The SQWE bit is read/writeable and can be cleared by RESET. SQWE is set to 1 when Vcc is turned on.

DM -- The Data Mode (DM) bit indicates whether the time and calendar information is in binary or BCD format. The DM bit is set by the program to provide the appropriate format and can be read as needed. This bit cannot be changed internally or by RESET. A '1' in DM indicates binary data while a '0' indicates DM is in BCD (Binary Coded Decimal) format.

24/12 -- This bit is used to select the clock mode, 24 or 12. '1' indicates 24-hour mode and '0' indicates 12-hour mode. This bit is read/writeable and is not affected internally or RESET.

DSE -- Is a special bit used to change the time when there is a change in season (usually occurs in countries with 4 seasons). When set to 1, on the first Sunday in April the clock changes from 1:59:59 AM to 3:00:00 AM. On the last Sunday in October when the time shows 1:59:59 AM it changes to 1:00:00 AM. This does not happen when DSE is set to 0. This bit is not affected internally or RESET.

Register C

| BIT 7 | BIT 6 | BIT 5 | BIT 4 | BIT 3 | BIT 2 | BIT 1 | BIT 0 |
|-------|-------|-------|-------|-------|-------|-------|-------|
| IRQF  | PF    | AF    | UF    | 0     | 0     | 0     | 0     |

IRQF -- The Interrupt Request Flag (IRQF) bit is set to 1 when the following occurs:

  • PF = PIE = 1
  • AF = AIE = 1
  • UF = UIE = 1

Contoh: IRQF = (PFPIE) + (AFAIE) + (UF*UIE)

When the IRQF bit is 1, the IRQ pin goes "low". The PF, AF, and UF flag bits are cleared after the C register is read by the program or when the RESET pin goes "low".

PF -- Periodic Interrupt Flag is a read-only bit that is set to 1 when an edge is detected at the selected tap in the division chain. The RS3 -- RS0 bits generate the periodic frequency. PF is set to 1 regardless of the PIE bit. When both PF and PIE are '1' , the IRQ signal is active and sets the IRQF bit. The PF bit is cleared by a software read to the C register or RESET.

AF -- A '1' on the Alarm Interrupt Flag (AF) bit indicates that the time reached corresponds to the alarm time. If the AIE bit is also 1, the IRQ pin will go low and a '1' will occur on the IRQF bit. A RESET or a read of register C will clear the AF.

UF -- The Update Ended Interrupt Flag bit is set after each update process. When the UIE bit is set to 1, the '1' in UF will cause the IRQF bit to become 1 and enable the IRQ pin. The UF is cleared by reading the C register or RESET.

BIT 3 to BIT 0 -- These bits are not used and always have a value of 0.

Register D

| BIT 7 | BIT 6 | BIT 5 | BIT 4 | BIT 3 | BIT 2 | BIT 1 | BIT 0 |
|-------|-------|-------|-------|-------|-------|-------|-------|
| VRT   | 0     | 0     | 0     | 0     | 0     | 0     | 0     |

VRT -- Valid RAM Time indicates the condition of the battery connected to the VBAT pin. This bit is not writable and is always 1 when read. A '0' will occur when the internal battery has failed. This bit is not affected by RESET.

BIT 6 to BIT 0 - These bits are not used and always have a value of 0.

Proses Update

The RTC 12C887 performs the update process once a second without considering the SET bit in register B. When the SET bit in register B is set to 1, the time, calendar, and alarm information will stop and will not change when the time is added, but the time calculation chain will continue and be stored in the internal buffer. This will maintain the time accuracy of the RTC when reading and writing. This update process will also compare the alarm byte with the time that occurred at that time.

There are three methods to access data on the RTC that will avoid inconsistent access to time information. The first method is to use the update ended interrupt. If enabled, an interrupt will occur each time the update process is completed, which gives 999 ms to read valid time data. If this interrupt is used, the IRQF bit in register C must be cleared before leaving the interrupt process.

The second method is to use the update in progress (UIP) bit in register A which indicates whether the update process is in progress. The UIP bit will emit a pulse every one second. After the UIP bit becomes high, the update process will occur 244 ?s later and if low is read on the UIP bit, then the user has 244 ?s before the time/calendar data will change. Therefore, the user must avoid interrupt processes that cause the data reading time to exceed 244 ?s.


Figure 14.3 Relationship between Update-Ended and Periodic Interrupt

The third method is to use periodic interrupts to indicate whether an update is in progress. The UIP bit in register A will be set high between activations of the PF bit in register C. An interrupt period exceeding tBUC will cause valid data to be reached at each interrupt. The read must be completed within (tPI/2 + tBUC) to ensure that data is not read during the update process.


Figure 14.6 RTC12c887 interface network

Experiment 14.1. Retrieval of second data on RTC DS12887 with LED display

In this experiment, the RTC seconds data is taken and output to the LED.


Figure 14.7. Interface circuit to LED

  1. Connect the LED_EN jumper
  2. Connect the data and control cables to the RTC board.
  3. Connect the Microcontroller Trainer module to the +5V power supply.
  4. Connect the Microcontroller Trainer module to the programmer circuit 
  5. Open the M-IDE Studio for MCS-51 program, as a program editor and compiler.
  6. Type the following program: ( download file prog141a.asm )
CS bit P3.3
ALE bit P3.2
Write bit P3.1
Read bit P3.0
PortData equ P0
RegisterA equ 10
RegisterB equ 11
           ;
org 0h
clr CS ; Aktivkan RTC
call INIT_RTC
start: mov PortData,#00h ; 00h = alamat detik pada RTC
       clr ALE ; Penguncian alamat 0-1-0
       setb ALE
       clr ALE
           ;
       setb Write ; sinyal write = 1
           ;
       setb Read
       clr Read ; sinyal read = 0
       mov A,PortData ; Baca data dari alamat 00h = detik
       setb Read
           ;
       mov P0,A ; simulasi data ke LED = P0
       sjmp start
           ;
INIT_RTC:
       setb Read
       mov PortData,#RegisterA ;
       clr ALE
       setb ALE
       clr ALE
           ;
       setb WRite
       clr Write
       mov PortData,#20h
       setb WRite
           ;
       mov PortData,#RegisterB
       clr ALE
       setb ALE
       clr ALE
           ;
       setb WRite
       clr WRite
       mov PortData,#02h
       setb WRite
           ;
       RET
      end
  1. Save the program you typed and name it: prog141a.asm
  2. In the MIDE program, select Build /F9 or to compile the program from *.asm to *.hex.
  3. Program the microcontroller using the ISP Software Program (See Instructions for Use).

Experiment 14.2. Retrieval of second and minute data on RTC12887 with 2x 16 Character LCD display.

In this experiment, second and minute data are taken and displayed on a 2x16 Character LCD.


Gambar 14.8 Interface LCD Carácter 2x16

  1. Connect the LCD_EN jumper
  2. Connect the data and control cables on the RTC board to the microcontroller circuit.
  3. Connect the Microcontroller Trainer module to the +5V power supply.
  4. Connect the Microcontroller Trainer module to the programmer circuit 
  5. Open the M-IDE Studio for MCS-51 program, as a program editor and compiler.
  6. Type the following program: ( download file prog142a.asm )
CS bit P3.3
ALE bit P3.2
Write bit P3.1
Read bit P3.0
PortRTC equ P2
RegisterA equ 10
RegisterB equ 11
Puluhan equ 30h
Satuan equ 31h
detik equ 32h
Menit equ 33h
     org 0h
call init_LCD
call init_RTC
; call setDetik
; call setMenit
call write_char
start:
      call readDetik
      call bin2Dec
      call write2LCDDetik
           ;
      call readMenit
      call bin2Dec
      call write2LCDMenit
           ;
      sjmp start
           ;
write_char:
      mov dptr,#word1 ;DPTR = [ address word1 ]
      mov r3,#16 ;R3=16,number character to be display
      mov r1,#80h ;R1=80h,address DDRAM start position
      acall write_inst
           ;
write1:clr a ; A = 0
      movc a,@a+dptr ; A = [A+ DPTR]
      mov r1,A ; R1 = A
      inc dptr ; DPTR = DPTR +1
      acall write_data;
      djnz r3,write1 ; R3 = R3-1,
      ret
           ;
Init_lcd:
   mov r1,#00000001b ;Display clear
   call write_inst ;
   mov r1,#00111000b;Function set,Data 8 bit,2linefont 5x7
   call write_inst ;
   mov r1,#00001100b ;Display on,cursor off,cursorblink off
   call write_inst
   mov r1,#00000110b ;Entry mode, Set increment
   call write_inst
   ret
           ;
Write_inst:
      clr P3.6 ; P3.6 = RS =0
      mov P0,R1 ; P0 = D7 s/d D0 = R1
      setb P3.7 ; P3.7 =EN = 1
      call delay ; call delay time
      clr P3.7 ; P3.7 =EN = 0
      ret
           ;
Write_data:
      setb P3.6 ; P3.6 = RS =1
      mov P0,R1 ; P0 = D7 s/d D0 = R1
      setb P3.7 ; P3.7 =EN = 1
      call delay ; call delay time
      clr p3.7 ; P3.7 =EN = 0
      ret
           ;
delay:mov R0,#0
      delay1: mov R7,#0fh
      djnz R7,$
      djnz R0,delay1
      ret
           ;
ReadDetik:
      mov PortRTC,#00h ;00h = alamat detik pada RTC
      clr ALE ;Penguncian alamat 0-1-0
      setb ALE
      clr ALE
      setb Write ; sinyal write = 1
           ;
      setb Read
      clr Read ; sinyal read = 0
      mov A,PortRTC ; Baca data dari alamat 00h = detik
      setb Read
      ret
           ;
ReadMenit:
      mov PortRTC,#02h ; 00h = alamat detik pada RTC
      clr ALE ; Penguncian alamat 0-1-0
      setb ALE
      clr ALE
      setb Write ; sinyal write = 1
           ;
      setb Read
      clr Read ; sinyal read = 0
      mov A,PortRTC ; Baca data dari alamat 00h = detik
      setb Read
      ret
           ;
init_RTC:
      clr CS
      setb Read
      mov PortRTC,#RegisterA ;
      clr ALE
      setb ALE
      clr ALE
           ;
      setb WRite
      clr Write
      mov PortRTC,#20h
      setb WRite
           ;
      mov PortRTC,#RegisterB
      clr ALE
      setb ALE
      clr ALE
           ;
      setb WRite
      clr WRite
      mov PortRTC,#06h
      setb WRite
      RET
           ;
Bin2Dec:
      mov b,#10d
      div ab
      mov puluhan,a
      mov satuan,b
      ret
           ;
Write2LCDDetik:
      mov r1,#0c4h
      call write_inst
      mov a,Puluhan
      add a,#30h
      mov r1,a
      call write_data
           ;
      mov r1,#0c5h
      call write_inst
      mov a,Satuan
      add a,#30h
      mov r1,a
      call write_data
      ret
           ;
 Write2LCDMenit:
           mov r1,#0c2h
           call write_inst
           mov a,Puluhan
           add a,#30h
           mov r1,a
           call write_data
           ;
           mov r1,#0c3h
           call write_inst
           mov a,Satuan
           add a,#30h
           mov r1,a
           call write_data
           ret
           ;
setMenit:
           setb Read
           mov PortRTC,#02h;
           clr ALE
           setb ALE
           clr ALE
           ;
           setb WRite
           clr Write
           mov PortRTC,#21d
           setb WRite
           ret
           ;
setDetik:
           setb Read
           mov PortRTC,#00h;
           clr ALE
           setb ALE
           clr ALE
           ;
           setb WRite
           clr Write
           mov PortRTC,#00h
           setb WRite
           ret
word1: DB ' My RTC Test '; here is the data to be look up
           end
  1. Save the program you typed and name it: prog142a.asm
  2. In the MIDE program, select Build /F9 or to compile the program from *.asm to *.hex.
  3. Program the microcontroller using the ISP Software Program (See Instructions for Use) 
  4. Make modifications to the program to display the hour, day, month and year data on the Character LCD.
  5. Modify the program to display seconds and minutes data on a 7-segment display.

MC-68705U3 Microcontroller Programmable Digital Timer & Clock

Seeing the advancement of technology and science, especially semiconductors which are closely related to the field of digital electronics, everything related to digital problems can be solved easily.

Microcontroller is a single chip microcomputer (SCM) which is a complete computer packaged in a chip (IC). Where in it there is RAM, ROM, or EPROM, timer, oscillator, ADC, I/Oport buffer, address channel and data channel so that it can work and be able to do complicated things even though the circuit is very simple.

With the simplicity of the tool using this microcontroller, the author tries to design and create a "Programmable Digital Clock using the MC 68705U3 Microcontroller". The reasons for choosing this type of MC 68705U3 are as follows:

  • The MC 68705U3 microcontroller and its manual are available in the market.
  • The microcontroller has 3 ports that can be programmed as inputs or outputs so that it can be connected to a display and time entry unit. 
  • The microcontroller has a timer consisting of an initial divider and a down counter, making it suitable for use as a time marker.

1. MC-68705U3 Microcontroller 

A microcontroller is a digital chip consisting of a microprocessor, ROM/EPROM, RAM and I/O components packaged in a chip.

The block diagram of the MC 68705U3 is shown in Figure 2.1 and the physical image and its pins are shown in Figure 2.2. The MC 68705U3 microcontroller has the following specifications:

  • Has an 8-bit CPU
  • Has a RAM memory of 112 bytes 
  • It has 3777 bytes of internal EPROM memory which is a place for application programs. 
  • It has 3 8-bit ports (Port A, B, and C) that can be set as input or output and one 8-bit port that functions as input. 
  • It has a timer consisting of a 7-bit pre-scaler and a programmable 8-bit TDR. 
  • It has 4 interrupt sources, 2 of which are external interrupts, namely INT and 8-bit programmable TDR.
  • Has a clock (clock generator) where the clock source can use a crystal, resistor, or wire.
  • I/0 mapping is a memory map.
  • Have research input 
  • Operates on a single +5 volt power supply. 
  • It has a bootstrap program on ROM as a digger for filling the EPROM.

2. Block Diagram 

Figure 2.1 shows the functional hardware block diagram of the MC 68705U3. The CPU contains an 8-bit Arithmetic Logic Unit (ALU), accumulator, program counter, index register, stack pointer, state code register, instruction decoder, timing and control logic. The MC 68705U3 has internal RAM so that this microcontroller operates without external memory.

The MC 68705U3 has parallel I/O whose functions can be programmed as input or output. The presence of a timer on the chip provides superior capabilities. The 8-bit counter and divider can initially be programmed for specific functions.


Figure 2.1 MC 68705U3 Hardware Block Diagram

2.1 Address Channels 

The address line is 12-bit, so the number of address locations that can be addressed is 4096 locations, namely from address 0 to 4096 (0000Hs/d OFFF). The I/0 unit uses the principle of memory mapping which means there is no special address for I/O, so the I/0 address uses part of the memory address quota or in other words a certain memory address is an I/O address. All addresses have been used so that nothing comes out of the microcontroller.


Figure 2.2 Embedding Diagram of MC 68705U3

2.2 Data Channels 

MC 68705U3 is an 8-bit microcomputer, where the data size and CPU are 8-bit. The I/O pins consisting of 32 pieces are grouped into 4 ports of 8-bit each. The tomer of the MC 68705U3 is also 8-bit. Because the data path has been used entirely in the IC, there is no data pin (external data channel). The microcontroller's connection to the outside world is done through I/0 and controllers.

2.3 Memory 

The MC 68705U3 microcontroller has 4096 memory locations (000H to FFH). This address on the MC 68705U3 is divided into I/0, REGISTER, Stack, RAM, EPROM and ROM addresses. The division of this address (memory map) is shown in the following figure:


Figure 2.3 Memory Mapping of MC 68705U3

2.4 Oscillators 

This oscillator is found in the MC 68705U3 which basically generates the clock used by the microcontroller system. The oscillator used is as shown in figure 2.4


Figure 2.3 Crystal Oscillator for MC 68705U3

2.5 Unit timer 

This timer consists of a 7-bit MOR (Mask Option Register), an 8-bit pre-scaler, a timer control register (Timer Contol Register), and an 8-bit timer data register (Timer Data Register).

MOR allows the initial divider to be fired directly from an external timer pin or from the internal clock 12. Whenever signal 12 is used when the timer pin is logic high.

3. Block diagram 

The alarm clock that will be planned is based on the MC 68705U3 microcontroller as shown in figure 3.1.


Figure 3.1 Block diagram of MC 68705U3 Alarm Clock

3.1 Unit Displai 

The display unit is planned to consist of 6 7-segment units, namely 2 for seconds, minutes and hours each.

The arrangement of segments of the display is shown in figure 3.2 and the connection of one display to port B is shown in figure 3.3. 

  • Figure 3.2 7-segment layout used
  • Figure 3.3 MC 68705U3 interface with 1 display

To display data on the display, a multiplexing circuit is required, namely a 3 to 8 decoder as shown in Figure 3.4.


Figure 3.2 7-segment layout used 


Figure 3.3 MC 68705U3 interface with 1 display 


MC 68705U3 Alarm Clock Schematic Diagram Image

3.3 Time Reference 

The type of oscillator used is a crystal type because it has a stable output frequency.

In this planning, the 1 second frequency for the clock comes from an external clock, namely an oscillator consisting of an RC circuit and a Schmitt-trigger inverter.


RC Oscillator and Schmitt-trigger Inverter Circuit

3.4 1 second interrupt 

The timer circuit is contained in the MC 68705U3. In the timer circuit, the TDR is reduced by 1 every time it gets a clock where the TDDR clock is taken from the initial output division.

To calculate the magnitude of the external oscillator frequency required to obtain one second, this can be done by selecting the divider and TDR set to 225.

3.5 Time Set Unit 

This unit functions to change the time that is already in memory to the desired time. This setting is done by providing logic that matches port D as in table 3.1.

This time validation unit is shown in Figure 3.6. The pull-up resistor is useful so that the input of port D is truly logic 0 depending on the switch.

3.6 Unit Alatm 

The alarm unit is controlled by port A (PA7) where the alarm will work if the PA7 output is logic 1 and will go off if PA7 is logic 0. The signal source to turn on the alarm is taken from the oscillator (figure 3.5.b).

3.7 Initialization Program 

This alarm clock program starts from IF8(h), so the FFE address is filled with F8 and the FFF address contains 01.

According to the port series of MC 68705U3 is set as follows: port A, port B as output. Thus DDR A, DDR B and DDR C are filled with logic 1. This port setting program is done with the following program:

3.8 Routine Timer Jam 

Each time interrupt occurs, the seconds will increase by one 1 (one). If the value of the second unit (address 20) has been 03 then the second unit is set back to 00 and the tens of seconds (address 21) increases by 1. If the tens of seconds has been 06 then the tens of seconds is set to 00 and the minute unit (address 23) increases by 1 (one). If the tens of minutes has been 06 then the tens of minutes is set to 00 and the hour unit has been 04, the value of the tens of hours needs to be checked whether it has been 02. If the tens of hours have been 02 the hour unit and the tens of hours (address 25) are set to 00.

3.9 Main Programs 

The main program contains initialization, getting the time display, calling the alarm set comparator, detecting whether the time setting data is available.

Main Programs

4. Program Completion 

This charging is controlled by the Bootstrap program, which has pin 8 receiving a voltage of 12 volts (minimum 9 volts and maximum 15 volts). The MC 68705U3 charging circuit is in the appendix.

4.2 Display Testing 

Display testing is done by hardware and software. Hardware testing consists of several stages, namely multiplexing testing, software testing is done by running the display program.

4.3 Alarm Unit Testing 

This test consists of testing the oscillator and alarm circuit. To get the desired sound frequency is done by adjusting the Trimpot, while to get a stronger sound level is done by increasing the transistor collector voltage.

4.4 Timer Testing 

This 1-second Timer Test is carried out by turning on and off segment a of 7-Segment digit 0 (zero). The segment will be on for 1 second and off for 1 second. 1-Second Timer Test Program

4.5 Alarm Clock Testing 

Alarm clock testing program

| Alamat              | Kode                         | Mnemonic                                          | Komentar                                                                  |
|---------------------|------------------------------|---------------------------------------------------|---------------------------------------------------------------------------|
| 170 173 176 177 179 | CD01F8 CD0234 9A BDD0 CC0176 | JSR INITIAL JSR SET WAKTU  CLI JSR TAMPIL JMP 176 | ; Inisialisasi ; Set waktu ; Enable interupsi  ; Tampilkan waktu ; Ulangi |

If this program is run, then every second the display appears, the seconds will increase and every 60 seconds, the minutes will increase by 1, and every 60 minutes, the hours will increase by 1.

4.6 System Testing 

Testing includes programming a digital clock and comparing the time on the clock with the time set to turn on the alarm.

The alarm setting time is at address 90 to 9B as shown in the following table where this time is filled in at the same time as filling in the program.

Time Set Table

| No          | Waktu Set                           | Isi Memory                                                                    | Kegiatan                                     |
|-------------|-------------------------------------|-------------------------------------------------------------------------------|----------------------------------------------|
| 1 2 3 4 5 6 | 08.00 10.30 10.45 12.30 13.30 16.60 | 90=08 91=00  92=10 93=30  94=10 95=45  96=12 97=30  98=13 99=30  9A=16 9B=00  | Masuk Istirahat Masuk Istirahat Masuk Pulang |

Conclusion 

After planning and making this digital clock, several conclusions can be drawn as follows:

  • By using the MC 68705U3 microcontroller, the digital clock circuit is simpler than using ordinary digital components.
  • By programming the timer unit of the MC 68705U3 microcontroller as a frequency divider, a certain time of 1 second can be marked. 
  • With the timer interrupt on the MC 687055U3, the 1 second timer signal will automatically cause the CPU to add 1 second. 
  • The presence of a dealer that is set as a time input on a digital clock can be adjusted to the actual time or the desired time. 
  • By using the MC 68705U3 microcontroller, the alarm sound time can be determined, where this time is stored in the EPROM memory. 
  • By using multiplexing technique, time data consisting of 6 digits can be seen simultaneously on the display even though the output port consists of 8-bits. Where this display is done alternately digit by digit. 
  • To ensure the display does not flicker, time data must be displayed at least every 20 min (50 Hz). 
  • This tool has worked as planned.

Source:

APPLICATION OF MICROCONTROLLER MC6870503 AS A PROGRAMMABLE TIMER AND DIGITAL CLOCK

By,

NIKAM SURBAKTI
Physics Study Program

Faculty of Mathematics and Natural Sciences,
University of North Sumatra

INTRODUCTION
©2004 Digitized by USU digital library 1

Bibliography:

  • MC 68705U3 Microcontroller Program and Circuit Making Guide by Ir. Busono, 1992
  • Circuit Design for Elektronic Instrumentation by Wobschall, 1987 
  • Microcomputer/ microprocessor User's Manual by Motorolla Inc., 1983 
  • Microcomputer Interfacing by Harold S.Stone, 1982 
  • Design with Microcontroler by Peatman, 1987 
  • Elektronic Principles and Application by Malvino/Leach, 1986 
  • Digital Technology with MOS Integrated Circuit by Ronald J.Webb, 1988 
  • Micoprocessor and Interpacing Programming and hardware by Douglas V.Hall, 1986.

Post a Comment

Previous Next

نموذج الاتصال