RTC(Real Time Clock)单元能在体系断电时经过体系备用电池供电,RTC能经过ARM的STRB/LDRB指令传输8位BCD数据到CPU,该数据包含时,分,秒,小时,天,月和年,RTC运用一个外部32.768KHZ的晶体也能履行报警功用。
报警功用。在掉电形式或正常作业形式下,RTC能够在指定的时刻发生报警信号。在正常作业形式下,报警中止(ALMINT)被激活。在掉电形式下,电源办理复苏信号PMWKUP也与ALMINT相同处于激活状态。RTC的报警寄存器(RTCALM)能够决议报警的使能或制止和报警时刻的设置条件。
节拍中止。RTC节拍时刻用于中止请求。TICNT寄存器具有一个中止使能位,一起其间的计数值用于中止。当计数值抵达0时,节拍时刻中止就会触发。中止的时刻距离核算如下:
中止的距离时刻 = (n+1)/128 单位是秒 其间n的值在1″127
下面的程序完成了,按一个键,能够更新当时时刻,能够经过串口发送数据修正当时时刻,设定报警寄存器,报警被触发后,会触发时刻节拍中止,中止时刻距离位1s,持续时刻是20s,也便是距离1s蜂鸣器响一下。按另一个键,中止节拍时刻中止,中止蜂鸣器。
#include “Font_Libs.h”
#include “2440addr.h”
#define _ISR_STARTADDRESS 0x33ffff00
#define pISR_EINT0 (*(unsigned *)(_ISR_STARTADDRESS+0x20))
#define pISR_T%&&&&&%K (*(unsigned *)(_ISR_STARTADDRESS+0x40))
#define pISR_RTC (*(unsigned *)(_ISR_STARTADDRESS+0x98))
#define pISR_EINT2 (*(unsigned *)(_ISR_STARTADDRESS+0x28))
#define pISR_UART0 (*(unsigned *)(_ISR_STARTADDRESS+0x90))
//笔直同步信号的脉宽、后肩和前肩
#define VSPW 15
#define VBPD 3
#define VFPD 5
//水平同步信号的脉宽、后肩和前肩
#define HSPW 8
#define HBPD 58
#define HFPD 15
#define CLKVAL 10
#define HOZVAL 319
#define LINEVAL 239
#define PWREN 1
#define MMODE 0
#define PNRMODE 3
#define BPPMODE 13
#define INVVCLK 0
#define INVVD 0
#define INVVDEN 0
#define U32 unsigned int
#define M5D(n) ((n) & 0x1fffff)
#define PAGEWIDTH 320
#define OFFSIZE 0
#define LCD_XSIZE 320
#define LCD_YSIZE 240
#define SCR_XSIZE 320
#define SCR_YSIZE 240
#define INVVLINE 1
#define INVVFRAME 1
#define BPP24BL 0
#define BSWP 0
#define HWSWP 0
volatile U32 LCD_BUFFER[240][320];
unsigned char data_buffer[7] = {5*16+1,1*16+7,1*16+9,2*16+6,7,1*16+2,1*16+0};
unsigned char alarm_buffer[6] ={0,1*16+8,0,0,0,0};
unsigned char *temp;
unsigned char str0[] = “当时时刻为”;
unsigned char str1[] = “年”;
unsigned char str2[] = “月”;
unsigned char str3[] = “日”;
unsigned char str[][7] = {“周日”,”星期一”,”星期二”,”星期三”,”周四”,”星期五”,”星期六”};
U32 flag, count, t, i;
void Init_LCD(){
rLCDCON1=(CLKVAL<<8)|(MMODE<<7)|(PNRMODE<<5)|(BPPMODE<<1)|0; //设置CLKVAL,VCLK=HCLK/[(CLKVAL+1)*2],决议VM的触发方法,挑选显现形式和BPP形式,暂时不要敞开LCD,由于还没有设置好
rLCDCON2=(VBPD<<24)|(LINEVAL<<14)|(VFPD<<6)|(VSPW); //rLCDCON2,rLCDCON3和rLCDCON4首要设置时序
rLCDCON3=(HBPD<<19)|(HOZVAL<<8)|(HFPD);
rLCDCON4=(HSPW);
rLCDCON5 = (BPP24BL<<12) | (INVVCLK<<10) | (INVVLINE<<9) | (INVVFRAME<<8) | (0<<7) | (INVVDEN<<6) | (PWREN<<3) |(BSWP<<1) | (HWSWP); //INVVLINE和INVVFRAME需求进行翻转,由于CPU宣布的是正脉冲,LCD运用的是负脉冲,所以要改动极性,PWREN使能电源信号
rLCDSADDR1=(((U32)LCD_BUFFER>>22)<<21)|M5D((U32)LCD_BUFFER>>1);
rLCDSADDR2=M5D(((U32)LCD_BUFFER+(SCR_XSIZE*SCR_YSIZE*4))>>1 );
rLCDSADDR3=PAGEWIDTH*32/16;
rLCDINTMSK|=(3);
rTCONSEL = 0;
rGPCUP = 0x0;
rGPDCON = 0xaaaaaaaa;
rGPCCON = 0xaaaa02a9;
rGPDUP = 0x0;
rGPGUP=rGPGUP&(“(1<<4))|(1<<4);
rGPGCON=rGPGCON&(“(3<<8))|(3<<8);
rLCDCON1 |= 1; //使能数据输出和LCD操控信号
}
声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/ziliao/254697.html