S3C2440-RTC中斷
報(bào)警功能。在掉電模式或正常工作模式下,RTC能夠在指定的時(shí)間產(chǎn)生報(bào)警信號(hào)。在正常工作模式下,報(bào)警中斷(ALMINT)被激活。在掉電模式下,電源管理蘇醒信號(hào)PMWKUP也與ALMINT一樣處于激活狀態(tài)。RTC的報(bào)警寄存器(RTCALM)可以決定報(bào)警的使能或禁止和報(bào)警時(shí)間的設(shè)置條件。
節(jié)拍中斷。RTC節(jié)拍時(shí)間用于中斷請(qǐng)求。TICNT寄存器具有一個(gè)中斷使能位,同時(shí)其中的計(jì)數(shù)值用于中斷。當(dāng)計(jì)數(shù)值到達(dá)0時(shí),節(jié)拍時(shí)間中斷就會(huì)觸發(fā)。中斷的時(shí)間間隔計(jì)算如下:
中斷的間隔時(shí)間 = (n+1)/128 單位是秒 其中n的值在1"127
下面的程序?qū)崿F(xiàn)了,按一個(gè)鍵,可以更新當(dāng)前時(shí)間,可以通過串口發(fā)送數(shù)據(jù)修改當(dāng)前時(shí)間,設(shè)定報(bào)警寄存器,報(bào)警被觸發(fā)后,會(huì)觸發(fā)時(shí)間節(jié)拍中斷,中斷時(shí)間間隔位1s,持續(xù)時(shí)間是20s,也就是間隔1s蜂鳴器響一下。按另一個(gè)鍵,停止節(jié)拍時(shí)間中斷,停止蜂鳴器。
#include "Font_Libs.h"
#include "2440addr.h"
#define _ISR_STARTADDRESS 0x33ffff00
#define pISR_EINT0 (*(unsigned *)(_ISR_STARTADDRESS+0x20))
#define pISR_TICK (*(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))
//垂直同步信號(hào)的脈寬、后肩和前肩
#define VSPW 15
#define VBPD 3
#define VFPD 5
//水平同步信號(hào)的脈寬、后肩和前肩
#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[] = "當(dāng)前時(shí)間為";
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; //設(shè)置CLKVAL,VCLK=HCLK/[(CLKVAL+1)*2],決定VM的觸發(fā)方式,選擇顯示模式和BPP模式,暫時(shí)不要開啟LCD,因?yàn)檫€沒有設(shè)置好
rLCDCON2=(VBPD<<24)|(LINEVAL<<14)|(VFPD<<6)|(VSPW); //rLCDCON2,rLCDCON3和rLCDCON4主要設(shè)置時(shí)序
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需要進(jìn)行翻轉(zhuǎn),因?yàn)镃PU發(fā)出的是正脈沖,LCD使用的是負(fù)脈沖,所以要改變極性,PWREN使能電源信號(hào)
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; //使能數(shù)據(jù)輸出和LCD控制信號(hào)
}
關(guān)鍵詞:
S3C2440RTC中斷節(jié)拍中
相關(guān)推薦
技術(shù)專區(qū)
- FPGA
- DSP
- MCU
- 示波器
- 步進(jìn)電機(jī)
- Zigbee
- LabVIEW
- Arduino
- RFID
- NFC
- STM32
- Protel
- GPS
- MSP430
- Multisim
- 濾波器
- CAN總線
- 開關(guān)電源
- 單片機(jī)
- PCB
- USB
- ARM
- CPLD
- 連接器
- MEMS
- CMOS
- MIPS
- EMC
- EDA
- ROM
- 陀螺儀
- VHDL
- 比較器
- Verilog
- 穩(wěn)壓電源
- RAM
- AVR
- 傳感器
- 可控硅
- IGBT
- 嵌入式開發(fā)
- 逆變器
- Quartus
- RS-232
- Cyclone
- 電位器
- 電機(jī)控制
- 藍(lán)牙
- PLC
- PWM
- 汽車電子
- 轉(zhuǎn)換器
- 電源管理
- 信號(hào)放大器
評(píng)論