基于ARM嵌入式系统接口技术课程设计报告

上传人:仙*** 文档编号:37530952 上传时间:2021-11-03 格式:DOC 页数:33 大小:524KB
返回 下载 相关 举报
基于ARM嵌入式系统接口技术课程设计报告_第1页
第1页 / 共33页
基于ARM嵌入式系统接口技术课程设计报告_第2页
第2页 / 共33页
基于ARM嵌入式系统接口技术课程设计报告_第3页
第3页 / 共33页
点击查看更多>>
资源描述
基于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 falling edge triggered./* UART */static int whichUart=0;void Uart_Init(int mclk,int baud) int i; if(mclk=0)mclk=MCLK; rUFCON0=0x0; /FIFO disable rUFCON1=0x0; rUMCON0=0x0; rUMCON1=0x0;/UART0 rULCON0=0x3; /Normal,No parity,1 stop,8 bit rUCON0=0x245; /rx=edge,tx=level,disable timeout int.,enable rx error int.,normal,interrupt or polling rUBRDIV0=( (int)(mclk/16./baud + 0.5) -1 );/UART1 rULCON1=0x3; rUCON1=0x245; rUBRDIV1=( (int)(mclk/16./baud + 0.5) -1 ); for(i=0;i100;i+);void Uart_Select(int ch) whichUart=ch;void Uart_TxEmpty(int ch) if(ch=0)while(!(rUTRSTAT0 & 0x4); /wait until tx shifter is empty. else while(!(rUTRSTAT1 & 0x4); /wait until tx shifter is empty.char Uart_Getch(void) if(whichUart=0) while(!(rUTRSTAT0 & 0x1); /Receive data readreturn RdURXH0(); else while(!(rUTRSTAT1 & 0x1); /Receive data readyreturnrURXH1; char Uart_GetKey(void) if(whichUart=0) if(rUTRSTAT0 & 0x1) /Receive data ready return RdURXH0();else return 0; else if(rUTRSTAT1 & 0x1) /Receive data ready return rURXH1;else return 0; void Uart_GetString(char *string) char *string2=string; char c; while(c=Uart_Getch()!=r) if(c=b) if(int)string2 (int)string ) Uart_Printf(b b);string-; else *string+=c; Uart_SendByte(c); *string=0; Uart_SendByte(n);int Uart_GetIntNum(void) char str30; char *string=str; int base=10; int minus=0; int lastIndex; int result=0; int
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 商业管理 > 销售管理


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!