已阅读5页,还剩28页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
基于arm嵌入式系统接口技术课程设计报告 课程设计题目:实时时钟设计 学院:计算机科学与技术学院 班级:计算机09-1班 学号: 姓名: 指导老师:微型计算机系统与接口技术课程设计设计时间:2011年12月19日 至 2011年12月23日设计环境1硬件环境:计算机,ev44b0ii实验台2软件环境:jediview 集成开发环境一、基本功能:利用s3c44box的rtc和实验箱上的lcd液晶、4*4小键盘设计一个实时时钟。1在lcd上显示当前日期及时间。可按如下格式显示:日期:xxxx年xx月xx日时间:xx:xx:xx 班级,姓名 里程: x x x x km2利用4*4小键盘校时 校时时lcd的相应位置要有光标提示。二、定时报警功能 通过小键盘设定报警时刻,报警时刻到,则在lcd上显示(各自不同的)报警图像。三、步骤: 1.掌握预备知识:a.液晶显示b.键盘译码c掌握s3c44bo芯片 rtc的使用方法 2.设计:a.实现rtc实时时钟功能b.显示实时时钟界面c.实现校时功能d.上机调试,运行,验收e.实现定时报警功能四、硬件接口逻辑图电路连接图五、程序代码(1)44binits/* * * name : 44binit.s* * version : 10.jan.2003* * description:* *c start up codes* *configure memory, initialize isr ,stacks* *initialize c-variables* *fill zeros into zero-initialized c-variables* */ /#include arm.h.globl _start_start: b resethandler /for debug b handlerundef /handlerundef b handlerswi /swi interrupt handler b handlerpabort /handlerpabort b handlerdabort /handlerdabort b . /handlerreserved b isrirq b handlerfiq/*important note*/if the h/w vectored interrutp mode is enabled, the above two instructions should/be changed like below, to work-around with h/w bug of s3c44b0x interrupt controller. ldr pc,=handlereint0 /mga h/w interrupt vector table ldr pc,=handlereint1 / ldr pc,=handlereint2 / ldr pc,=handlereint3 / ldr pc,=handlereint4567 / ldr pc,=handlertick /mga b . b . ldr pc,=handlerzdma0 /mgb ldr pc,=handlerzdma1 / ldr pc,=handlerbdma0 / ldr pc,=handlerbdma1 / ldr pc,=handlerwdt / ldr pc,=handleruerr01 /mgb b . b . ldr pc,=handlertimer0 /mgc ldr pc,=handlertimer1 / ldr pc,=handlertimer2 / ldr pc,=handlertimer3 / ldr pc,=handlertimer4 / ldr pc,=handlertimer5 /mgc b . b . ldr pc,=handlerurxd0 /mgd ldr pc,=handlerurxd1 / ldr pc,=handleriic / ldr pc,=handlersio / ldr pc,=handlerutxd0 / ldr pc,=handlerutxd1 /mgd b . b . ldr pc,=handlerrtc /mgka b . / b . / b . / b . / b . /mgka b . b . ldr pc,=handleradc /mgkb b . / b . / b . / b . / b . /mgkb b . b ./*0xe0=enterpwdn*/ ldr pc,=enterpwdnhandlerfiq:.word handlefiqhandlerirq:.word handleirqhandlerundef:.word handleundefhandlerswi:.word handleswihandlerdabort:.word handledaborthandlerpabort:.word handlepaborthandleradc:.word handleadchandlerrtc:.word handlertchandlerutxd1:.word handleutxd1handlerutxd0:.word handleutxd0handlersio:.word handlesiohandleriic:.word handleiichandlerurxd1:.word handleurxd1handlerurxd0:.word handleurxd0handlertimer5:.word handletimer5handlertimer4:.word handletimer4handlertimer3:.word handletimer3handlertimer2:.word handletimer2handlertimer1:.word handletimer1handlertimer0:.word handletimer0handleruerr01:.word handleuerr01handlerwdt:.word handlewdthandlerbdma1:.word handlebdma1handlerbdma0:.word handlebdma0handlerzdma1:.word handlezdma1handlerzdma0:.word handlezdma0handlertick:.word handletickhandlereint4567:.word handleeint4567handlereint3:.word handleeint3handlereint2:.word handleeint2handlereint1:.word handleeint1handlereint0:.word handleeint0/*one of the following two routines can be used for non-vectored interrupt.*/isrirq:/using i_ispr register.stmdb r13!,r0-r8,r12,r14bl irqldmia r13!,r0-r8,r12,r14subs pc,r14,#0x4irq: sub sp,sp,#4 /reserved for pc stmfd sp!,r8-r9 ldr r9,i_ispr ldr r9,r9 mov r8,#0x0f0: movs r9,r9,lsr #1 bcs f1 add r8,r8,#4 b f0f1: ldr r9,handleadc add r9,r9,r8 ldr r9,r9 str r9,sp,#8 ldmfd sp!,r8-r9,pc/* *start * */resethandler: ldr r0,wtcon /watch dog disable ldr r1,=0x0 str r1,r0 ldr r0,intmsk ldr r1,maskall /all interrupt disable str r1,r0/* * *set clock control registers* */ ldrr0,locktime ldrr1,=800 / count = t_lock * fin (t_lock=200us, fin=4mhz) = 800 strr1,r0ldrr0,pllcon/temporary setting of pllldrr1,pllcon_dat /fin=10mhz,fout=40mhzstrr1,r0 ldr r0,clkcon ldr r1,=0x7ff8 /all unit block clk enable str r1,r0/* * *set memory control registers* */ adr r0,smrdata ldmia r0,r1-r13 ldr r0,=0x01c80000 /bwscon address stmia r0,r1-r13/* * *initialize stacks* */ ldr sp, svcstack/why? bl initstacks/* * *setup irq handler* */ ldr r0,handleirq/this routine is needed ldr r1,isrirq/if there isnt subs pc,lr,#4 at 0x18, 0x1c str r1,r0 blmain /dont use main() because . b./*the function for initializing stack */*/initstacks:/dont use dram,such as stmfd,ldmfd./svcstack is initialized before/under toolkit ver 2.50, msr cpsr,r1 can be used instead of msr cpsr_cxsf,r1 mrs r0,cpsr bic r0,r0,#0x1f orr r1,r0,#0xdb/undefmode|noint msr cpsr,r1/undefmode ldr sp,undefstack orr r1,r0,#0xd7/abortmode|noint msr cpsr,r1 /abortmode ldr sp,abortstack orr r1,r0,#0xd2/irqmode|noint msr cpsr,r1 /irqmode ldr sp,irqstack orr r1,r0,#0xd1/fiqmode|noint msr cpsr,r1 /fiqmode ldr sp,fiqstack bic r0,r0,#0xdf/modemask|noint orr r1,r0,#0x13 msr cpsr,r1 /svcmode ldr sp,svcstack/user mode is not initialized. mov pc,lr /the lr register may be not valid for the mode changes./* *the function for entering power down mode * */*void enterpwdn(int clkcon)*/enterpwdn: mov r2,r0 /r0=clkcon ldr r0,refresh ldr r3,r0 mov r1, r3 orr r1, r1, #0x400000 /self-refresh enable str r1, r0 nop /wait until self-refresh is issued. may not be needed. nop /if the other bus master holds the bus, . nop / mov r0, r0 nop nop nop nop/*enter powerdn mode*/ ldr r0,clkcon str r2,r0/*wait until enter sl_idle,stop mode and until wake-up*/ mov r0,#0xff b0: subs r0,r0,#1 bneb0/*exit from dram/sdram self refresh mode.*/ ldr r0,refresh str r3,r0 mov pc,lrsmrdata:/* * memory configuration has to be optimized for best performance * * the following parameter is not optimized. * */* memory access cycle parameter strategy */ 1) even fp-dram, edo setting has more late fetch point by half-clock/ 2) the memory settings,here, are made the safe parameters even at 66mhz./ 3) fp-dram parameters:trcd=3 for trac, tcas=2 for pad delay, tcp=2 for bus load./ 4) dram refresh rate is for 40mhz. */ .long 0x11110090/bank0=om1:0, bank1bank7=16bit, bank2=8bit/ .long 0x600/gcs0.long 0x7bc0/gcs1 .long 0x7fc0/gcs2.long 0x7ffc/gcs3.long 0x7ffc/gcs4.long 0x7ffc/gcs5.long 0x18000/gcs6.long 0x18000/gcs7.long 0x820591/refresh rfen=1, trefmd=0, trp=3clk, trc=5clk, tchr=3clk,count=1019.long 0x16/sclk power mode, banksize 32m/32m.long 0x20/mrsr6 cl=2clk.long 0x20/mrsr7userstack:.word0xc7ffa00svcstack:.word0xc7ffb00undefstack:.word0xc7ffc00abortstack:.word0xc7ffd00irqstack:.word0xc7ffe00fiqstack:.word0xc7fff00handlereset:.word0xc7fff00handleundef:.word0xc7fff04handleswi:.word0xc7fff08handlepabort:.word0xc7fff0chandledabort:.word0xc7fff10handlereserved:.word0xc7fff14handleirq:.word0xc7fff18handlefiq:.word0xc7fff1c/dont use the label intvectortable,/because armasm.exe cannt recognize this label correctly./the value is different with an address you think it may be./intvectortablehandleadc:.word0xc7fff20handlertc:.word0xc7fff24handleutxd1:.word0xc7fff28handleutxd0:.word0xc7fff2chandlesio:.word0xc7fff30handleiic:.word0xc7fff34handleurxd1:.word0xc7fff38handleurxd0:.word0xc7fff3chandletimer5:.word0xc7fff40handletimer4:.word0xc7fff44handletimer3:.word0xc7fff48handletimer2:.word0xc7fff4chandletimer1:.word0xc7fff50handletimer0:.word0xc7fff54handleuerr01:.word0xc7fff58handlewdt:.word0xc7fff5chandlebdma1:.word0xc7fff60handlebdma0:.word0xc7fff64handlezdma1:.word0xc7fff68handlezdma0:.word0xc7fff6chandletick:.word0xc7fff70handleeint4567:.word0xc7fff74handleeint3:.word0xc7fff78handleeint2:.word0xc7fff7chandleeint1:.word0xc7fff80handleeint0:.word0xc7fff84/* some parameters for the board */*interrupt control*/intpnd:.long 0x01e00004intmod:.long 0x01e00008intmsk:.long 0x01e0000ci_ispr:.long 0x01e00020i_cmst:.long 0x01e0001c/*;watchdog timer*/wtcon:.long 0x01d30000/*;clock controller*/pllcon:.long 0x01d80000clkcon:.long 0x01d80004locktime:.long 0x01d8000c/*;memory controller*/refresh:.long 0x01c80024/*;pre-defined constants*/usermode:.long 0x10fiqmode:.long 0x11irqmode:.long 0x12svcmode:.long 0x13abortmode:.long 0x17undefmode:.long 0x1bmodemask:.long 0x1fnoint:.long 0xc0_isr_startaddress:.long 0xc7fff00 /gcs6:64m dram/sdrampllclk:.long40000000pllcon_dat: .long (2 0) + (3 4) +( 0x48 12)maskall:.long 0x07ffffff(2)44blcd.c#include #include #include .incoption.h#include .incdef.h#include .inc44b.h#include .inc44blib.h/#include .inclcd.h#include .inclcdlib.h#include .inc44blcd.h#include .incclock.h#include .incplm.hvoid clrscreen(void);void lcd_monoinit(void);extern int hour,min,sec,year,month,day,ye;#define framebuffer1 0xc400000void lcdinit(void) lcd_monoinit(); clrscreen(); /displaylcd(); display(10,4,3); display(10,4,6); void lcd_monoinit(void) /160x240 1bit/1pixel lcd #define mval_used 0rlcdcon1=(0)|(15)|(mval_used7)|(0x38)|(0x310)|(clkval_mono12); / disable,4b_sngl_scan,wdly=8clk,wlh=8clk,rlcdcon2=(lineval)|(hozval10)|(1021); /lineblank=10 (without any calculation) rlcdsaddr1= (0x022)1); / monochrome, lcdbank, lcdbaseurlcdsaddr2= m5d( (u32)framebuffer1+(scr_xsize*lcd_ysize/8)1) ) | (mval21)|(129);rlcdsaddr3= (lcd_xsize/16) | ( (scr_xsize-lcd_xsize)/16)9 );rlcdcon1=(1)|(15)|(mval_used7)|(0x38)|(0x310)|(clkval_mono12); / enable,4b_sngl_scan,wdly=8clk,wlh=8clk,void clrscreen(void) int i,j;unsigned int *pbuffer;pbuffer =(u32*) framebuffer1; for (i=0;i4,3,1); display(ye&0xf,3,2); display(year4,3,3); display(year&0xf,3,4); display(month4,3,6); display(month&0xf,3,7); display(day4,3,9); display(day&0xf,3,10); display(hour4,4,1); display(hour&0xf,4,2); display(min4,4,4); display(min&0xf,4,5); display(sec4,4,7); display(sec&0xf,4,8); void display(unsigned int code,unsigned char line,unsigned char xdot) unsigned short *pbuffer; unsigned char i; pbuffer =(u16*) framebuffer1; for (i=0;i16;i+) pbuffer20*i+320*line+xdot=(rtclockcode.datai*2)+(rtclockcode.datai*2+18);void displaylcd(void) unsigned int *pbuffer,temp_data; int i; unsigned char *buf; buf= (unsigned char *)plm; pbuffer =(u32*) framebuffer1; for(i = 0; i (4800/4) ;i+) temp_data = (bufi*4+3 24) + (bufi*4+2 16) + (bufi*4+1 8) +(bufi*4); pbufferi = temp_data;delay(10); / +void disstrhzk(char * hzku, int x1, int y1 ,unsigned char color,int charcount) int i;int j;unsigned char hz; int xx,yy;char * hzk;unsigned char flag = 128;for(hzk=hzku,xx=x1,yy=y1;(hzk-hzku)charcount;hzk+=32)for(i=0;i16;i+)hz=hzk2*i;for(j=0;jj) putpixelcolor(xx+j,yy+i,color);hz=hzk2*i+1;for(j=0;jj) putpixelcolor(xx+8+j,yy+i,color);xx+=16;if(xx=(scr_xsize-16)xx=x1;yy+=16;(3)44blib.c/* * name : 44blib.c* */#include .inc44b.h#include .inc44blib.h#include .incdef.h#include .incoption.h#include #include #include #include #include /* system */static int delayloopcount=400;void delay(int time)/ time=0: adjust the delay function by watchdog timer./ time0: the number of loop time/ 100us resolution. int i,adjust=0; if(time=0) time=200;adjust=1;delayloopcount=400;rwtcon=(mclk/1000000-1)8)|(23); / 1m/64,watch-dog,nreset,interrupt disablerwtdat=0xffff;rwtcnt=0xffff; rwtcon=(mclk/1000000-1)8)|(23)|(10;time-)for(i=0;idelayloopcount;i+); if(adjust=1) rwtcon=(mclk/1000000-1)8)|(23);i=0xffff-rwtcnt; / 1count/16us?delayloopcount=8000000/(i*64);/400*100/(i*64/200) /* ports */void port_init(void) /caution:follow the configuration order for setting the ports. / 1) setting value / 2) setting control register / 3) configure pull-up resistor. /port a group /gpa9 addr23 addr22 addr21 addr20 addr19 addr18 addr17 addr16 addr0 / 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 rpcona=0x1ff; rpdata=0x0; /port b group /gpb10 gpb9 ngcs3 ngcs2 ngcs1 gpb5 gpb4 nsras nscas sclk scke / 0, 0, 1,1, 1, 0, 0,1, 1, 1, 1 rpconb=0x1cf; /port c group /iislrck iisd0 iisdi iisclk vd7 vd6 vd5 vd4 nxdack1 nxdreq1 gpc10 gpc11 txd1 rxd1 gpc14 gpc15 /all input / 11 11 11 11 11 11 11 11 11 11 0101 11 11 01 01 rpdatc=0x8400; rpconc=0x5f5fffff; rpupc=0x33ff;/should be enabled /port d group /vframe vm vline vclk vd3 vd2 vd1 vd0 / 10,10, 10,10, 10,10, 10,10 rpcond=0xaaaa; rpupd=0xff; /port e group /pe0:fout, pe1:txd0, pe2:rxd0, gpe3, gpe4, gpe5,gpe6,gpe7, codeclk / 10 10, 10, 01 , 01, 01, 01, 01, 10 rpcone=0x2552b; rpupe=0x0; rpdate=0x60; /port f group /iicscl iicsda nwait nxback0 nxdreq0 gpf5 gpf6 gpf7 gpf8 / 10 10 10 10 10 0 0 0 0 rpconf=0x2a; rpupf=0x0; /port g group /eint0 eint1 eint2 eint3 gpg4 gpg5 gpg6 gpg7 / 0x0 / 11 11 11 11 01 01 01 01 rpdatg=0x0; rpcong=0x55ff; rpupg=0x0; rspucr=0x7; /pull-up disable rextint=0x22222022; /all eint7:0 will be fal
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 智能邮件分类技术课程设计
- PCA降维实战课程设计
- 比赛规则讲解课程设计
- 初中课程设计软件
- 搜索引擎算法设计课程设计
- 市政园林模拟试题及详细答案
- OCR技术身份证信息提取方法课程设计
- 贝叶斯网络健康监测课程设计
- 数字借阅系统开发实践课程设计
- 电动自行车动力系统设计资料课程设计
- 英语中人名的课件
- 《康复技术》课件-第七章创伤性及中毒性脑脊髓损伤康复-第一节 颅脑损伤的康复
- 2026届新高考物理冲刺复习:圆周运动的临界问题
- 推进6S生产现场管理工作实施方案
- 【人教版化学】选择性必修1 知识点默写小纸条(空白默写版)
- 运动障碍护理查房
- 南京市2025届高三年级学情调研(零模)地理试卷(含答案)
- 对折剪纸课公开课件
- DL∕T 5210.4-2018 电力建设施工质量验收规程 第4部分:热工仪表及控制装置
- 钢结构工程施工钢结构安装方案
- 林业生态工程学课件
评论
0/150
提交评论