LPC2134 Learning Log (Part 2) -- LCD12864 Clock

Publisher:蓝天飞行Latest update time:2016-04-05 Source: eefocusKeywords:LPC2134 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
These two weeks seem to be a bit busy, making Lazy Cat physically and mentally exhausted, and sometimes even unable to help but get angry with others. Lazy Cat is very sorry for this, and I would like to say sorry here, and hope you can understand. Well, no matter how busy I am, Lazy Cat must find time to learn something. As the old saying goes, learning is like sailing, if you don't advance, you will retreat. Although Lazy Cat loves to fly, he has not learned to fly yet, so for Lazy Cat's dream of traveling around the world, Lazy Cat must work hard and work hard again!

Well, okay, without further ado, I took the time these days to write based on the previous blog, and added some things to make a real-time clock. Of course, the functions are not complete yet, there is no function to adjust the time, no timing function, and there is no function to add a menu on LCD12864... Anyway, this is the simplest real-time clock. The main purpose is to learn about the RTC inside LPC2134. Although the program can run, there is a small BUG during simulation, that is, the second value is updated only once every 3 seconds, which makes the lazy cat very depressed. I have been searching for the reason for a long time but have not found it. However, the lazy cat did not give up and kept looking until it was eliminated. If you have written a program in this area, you can also guide the lazy cat. The lazy cat will be very grateful. Thank you very much.

OK, here is the interface diagram for this simulation. I would like to emphasize that this is only used for simulation in Proteus and cannot be used for actual welding:

sch.bmp

Figure 1-1  Simulation circuit diagram

Since this real-time clock is modified based on the previous log "LPC2134 Learning Log  Learning to Use LCD12864", only two files, Clock.h and Clock.c, are added. The advantage of adding this is modular programming, but if it is not used, it can be deleted directly, and the template does not need to be changed back and forth. The following is the content of CLOCK.H:

 

 

//File name: Clock.h

//    Function : some functions about timer

//    Author : Lazy Cat Loves to Fly

//    Note  : MCU      -- LPC2134

//           Crystal   -- 12MHz

//           RTC       -- 32.768KHz  

//           Development environment--  RealView MDK-ARM Verxion 4.12

 

#ifndef __CLOCK_H__

#define __CLOCK_H__

 

#include "config.h"

 

#define RTC_NUM 13

#define T0_NUM 4  

 

 

struct {

        uint8 second;   //  Record  seconds

        uint8 minute;   //  Record  minutes

        uint8 hour;     //  Record  time

                  uint8 year;     //  Record  year

                  uint8 month;    //  Record  month

                  uint8 day;      //  Record  day

                  uint8 week;     //  Record  the week

       } current_time,pre_time;

 

#define Cur_Sec    current_time.second

#define Cur_Min    current_time.minute

#define Cur_Hour   current_time.hour

#define Cur_Year   current_time.year

#define Cur_Month current_time.month

#define Cur_Day    current_time.day

#define Cur_Week   current_time.week

 

#define Pre_Sec    pre_time.second

#define Pre_Min    pre_time.minute

#define Pre_Hour   pre_time.hour

#define Pre_Year   pre_time.year

#define Pre_Month pre_time.month

#define Pre_Day    pre_time.day

#define Pre_Week   pre_time.week

 

struct {

        uint32 timet;   //  Read the current time from the register

        uint32 datet;   //  Read the date from the current register

       } rtc_time;

 

#define Timet   rtc_time.timet

#define Datet   rtc_time.datet

 

BOOL t0flag;                         //  Timer flag

BOOL secflag;           //  Seconds flag

BOOL dotflag;           //  The colon between minutes and seconds displays the flag

 

extern void RTC_Init(void);     //RTC initialization

extern void Timer0_Init(void); //  Timer 0 initialization

extern void T0_Process(void);   //  Timer 0 processing program

extern void Updata_Time(void); //  Update time

 

#endif

This file mainly declares some global variables and some functions related to writing RTC and timer, among which BOOL

This data type is customized by me and is declared as follows in config.h:

//Define binary variables using union

typedef enum

{

    FALSE = 0,

    TRUE   = 1,

} BOOL;

The following functions are called in the main function, so the keyword extern must be added. I will not post the contents of the Clock.c file here, as it is a bit long. If you are interested, you can refer to the attachment, which contains source code and project files. The compilation environment is MDK4.12. Here I would also like to talk about the Show_Time (uint8 svalue, uint vposi) function. This function is used to display the corresponding position on the LCD after updating the data. One thing to note is that you must clear that position to 0 before redisplaying, otherwise garbled characters will appear. As shown in the following program:

 

void Show_Time(uint8 svalue,uint8 vposi)

{

   uint8 i = 0;

   uint8 hb = 0; //  Storage time tens digit

   uint8 lb = 0; //  Store time units

   hb = svalue;

   for(i=0;i<2;i++)

      

      lb = hb;

      hb /= 10;

      Show_Num(6,timeposi[i+vposi],10);   //  Clear the position where the data is updated, otherwise garbled characters may appear

      Show_Num(6,timeposi[i+vposi],lb);

   }

}

 

OK, that's all I have to summarize for now. It's time to get back to work. Otherwise, my boss might think I'm playing around again. I'll check for bugs when I get home tonight.

Keywords:LPC2134 Reference address:LPC2134 Learning Log (Part 2) -- LCD12864 Clock

Previous article:S3C6410 bare metal timer
Next article:LPC2134 Learning Log -- LCD12864 Learning

Recommended ReadingLatest update time:2024-11-16 20:46

A powerful explanation of the clock setting operation of the PIC microcontroller
  The clock signal of the microcontroller is like the heart of the microcontroller. The clock frequency of the microcontroller determines the time it takes for the microcontroller to run an instruction cycle. The principle is that the crystal oscillator and the external capacitor form a capacitor three-point oscillati
[Microcontroller]
A powerful explanation of the clock setting operation of the PIC microcontroller
Clock circuit PCB program based on STC89C51 DS1302+LCD1602
The actual picture produced is as follows:   The simulation schematic diagram is as follows (the proteus simulation project file can be downloaded in the attachment of this post) The schematic diagram and PCB diagram drawn by Altium Designer are as follows: (the project file can be downloaded in the attachment of
[Microcontroller]
Clock circuit PCB program based on STC89C51 DS1302+LCD1602
STM32 system learning - RCC (using HSE/HSI to configure clock)
RCC: reset clock control reset and clock controller. Mainly explain the clock part, especially the clock tree. After understanding the clock tree, you will know the ins and outs of all the clocks of STM32. 1. The main function of RCC - clock part  Set the system clock SYSCLK, set the AHB division factor (determine
[Microcontroller]
STM32 system learning - RCC (using HSE/HSI to configure clock)
Single chip LCD12864 unlimited expansion multi-level menu source code
The microcontroller source program is as follows: #include "delay.h" #include "12864.h" #include "fun.h" #include "key.h" #include "wakeup.h" u8  func_index=0; void (*current_operation_index)(); //Execute the current display function typedef struct    {         u8 current; //Current status number         u8 up; //S
[Microcontroller]
Research and design of a multi-clock network-on-chip based on FPGA
Designing a high-performance, flexible, and small-area communication architecture on FPGA is a huge challenge. Most FPGA-based on-chip networks run on a single clock. With the development of FPGA technology, Xilinx has launched the Virtex-4 platform. This platform supports 32 clocks running at the same time, which m
[Embedded]
Research and design of a multi-clock network-on-chip based on FPGA
STM8S TIM1 clock division
[Microcontroller]
STM8S TIM1 clock division
About the application of AT89C51 system clock interrupt
Powerful clock interrupt In microcontroller programming, setting a good clock interrupt will enable one CPU to play the role of two CPUs, greatly facilitate and simplify program preparation, and improve the efficiency and operability of the system. We can put some routine programs that need to be executed regularly in
[Microcontroller]
Design of DPLL for Extracting Bit Synchronous Clock Based on FPGA
In digital communication systems, synchronization technology is very important, and bit synchronization is the most basic synchronization. The bit synchronization clock signal is not only used to monitor the input code element signal to ensure the synchronization of transmission and reception, but also provides a refer
[Embedded]
Design of DPLL for Extracting Bit Synchronous Clock Based on FPGA
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号