嵌入式

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

1实验一;汇编指令实验//注意格式为什么空两格;定义端口E寄存器预定义rGPFCONEQU0x56000050rGPFDATEQU0x56000054rGPFUPEQU0x56000058AREAInit,CODE,READONLY;该伪指令定义了一个代码段,段名为Init,属性只读ENTRY;程序的入口点标识ResetEntry;下面这三条语句,主要是用来设置I/O口GPE7为输出属性ldrr0,=rGPFCON;将寄存器rPCONE的地址存放到寄存器r0中ldrr1,=0x4000strr1,[r0];将r1中的数据存放到寄存器rPCONE;下面这三条语句,主要是禁止GPE端口的上拉电阻ldrr0,=rGPFUPldrr1,=0xffffstrr1,[r0]ldrr2,=rGPFDAT;将数据端口E的数据寄存器的地址附给寄存器rledloopldrr1,=0x1ffffstrr1,[r2];使GPE7输出高电平,D9灯会灭bldelay;调用延迟子程序ldrr1,=0x0strr1,[r2];使GPE7D9灯亮bldelay;调用延迟bledloop;不断的循环,D9将不停的闪烁;下面是延迟子程序delayldrr3,=0x1ffff;设置延迟的时间delay1subr3,r3,#1;r3=r3-1cmpr3,#0x0;将r3的值与0相比较bnedelay1;比较的结果不为0(r3不为0),继续调用delay1,否则执行下一条语句movpc,lr;返回END;程序结束符实验二步进电机与彩灯结合C程序部分:c程序调用汇编#defineGPFCON(*(volatileunsigned*)0x56000050)#defineGPFDAT(*(volatilechar*)0x56000054)externvoidstart(int);//外部声明2voidDlay(void);intMain(void){GPFCON=0X5500;//设置控制寄存器初值设置登的端口位输出01表示输出,00为输入;while(1){GPFDAT=0xe0;Dlay();GPFDAT=0xD0;Dlay();GPFDAT=0xB0;Dlay();GPFDAT=0x70;Dlay();GPFDAT=0xF0;Dlay();start(1);//返回一个值个r0=1;调用汇编程序Dlay();Dlay();Dlay();GPFDAT=0xe0;Dlay();GPFDAT=0xD0;Dlay();GPFDAT=0xB0;Dlay();GPFDAT=0x70;Dlay();GPFDAT=0xF0;Dlay();start(0);//返回r0=0;执行反转,调用汇编程序//执行灯亮的顺序GPFDAT=0xe0;Dlay();GPFDAT=0xD0;Dlay();GPFDAT=0xB0;Dlay();GPFDAT=0x70;Dlay();GPFDAT=0xF0;Dlay();}}voidDlay(void){inti,j;for(i=0;i500;i++)for(j=0;j2100;j++);}汇编程序:sTUPEQU0x38001000;定义步进电机的地址值AREAInit,CODE,READONLY;该伪指令定义了一个代码段,段名为Init,属性只读EXPORTstart;声明start,以便外部程序使用ENTRY;程序入口IMPORTMain;声明Main函数可以被其他文件使用BlMain;跳转,从Main函数开始执行startmovr9,lr//保存入口地址,用于调用后返回cmpr0,#1ldrr6,=sTUP3ldrr10,=0x0001ebnefanzhuan//start=1,跳转zhengzhuanldrr7,=0x01strr7,[r6]bldelayldrr7,=0x02strr7,[r6]bldelayldrr7,=0x04strr7,[r6]bldelayldrr7,=0x08strr7,[r6]bldelaysubr10,r10,#1cmpr10,#0x0bnezhengzhuanldrr10,=0x0001emovpc,r9//回到调用程序之前的位置fanzhuanldrr7,=0x08strr7,[r6]bldelayldrr7,=0x04strr7,[r6]bldelayldrr7,=0x02strr7,[r6]bldelayldrr7,=0x01strr7,[r6]bldelaysubr10,r10,#1cmpr10,#0x0bnefanzhuanldrr10,=0x0001emovpc,r9//回到调用程序之前的位置delayldrr11,=0x0ffffdelay1subr11,r11,#1cmpr11,#0x0bnedelay14movpc,lr;子程序返回END实验3点阵实验汇编入口程序:AREAInit,CODE,READONLYIMPORTMainENTRYblMainENDC程序:#definedianzhen(*(volatileunsignedshort*)0x80001000)voiddelay(unsignedinti);unsignedshorttable[]={0xaefe,0x24fd,0xfffb,0x24f7,0x6eef,0x35df,0xa6bf,0x647f,//我0x7cfe,0x10fd,0x7efb,0x10f7,0x10ef,0x10df,0x18bf,0x107f,//于0x3cfe,0x04fd,0x04fb,0x3cf7,0x04ef,0x04df,0x3cbf,0x007f,//e0x3cfe,0x04fd,0x04fb,0x3cf7,0x04ef,0x04df,0x04bf,0x007f,//f0x18fe,0x24fd,0x24fb,0x24f7,0x24ef,0x24df,0x18bf,0x007f,//00x18fe,0x1cfd,0x18fb,0x18f7,0x18ef,0x18df,0x18bf,0x3c7f,//10x38fe,0x44fd,0x20FB,0x10F7,0x08EF,0x04DF,0x7cBF,0X007F,//20x38fe,0x44fd,0x20fb,0x10f7,0x20ef,0x44df,0x38bf,0x007f,//30x20fe,0x30fd,0x28fb,0x24f7,0xfeef,0x20df,0x20bf,0x007f,//40x3cfe,0x04fd,0x04FB,0x3cF7,0x40EF,0x40DF,0x44BF,0X387F,//50x10fe,0x08fd,0x04fb,0x1ef7,0x22ef,0x22df,0x22bf,0x1c7f,//60x3efe,0x20fd,0x10fb,0x08f7,0x08ef,0x08df,0x08bf,0x087f,//70x3cfe,0x42fd,0x42FB,0x3cF7,0x42EF,0x42DF,0x42BF,0X3c7F,//80x38fe,0x44fd,0x44fb,0x44f7,0x38ef,0x20df,0x10bf,0x087f,//90x00fe,0x32fd,0x4afb,0x4af7,0x4aef,0x4adf,0x32bf,0x007f,//100x00fe,0x24fd,0x24FB,0x24F7,0x24EF,0x24DF,0x24BF,0X007F,//11};intMain(void){unsignedinti,n,j;while(1){delay(1000);for(n=0;n14;n++)//扫描显示的字符{for(j=0;j1000;j++)//扫描速度{for(i=0;i9;i++)//扫描8个数组,即一个字符{dianzhen=table[i+8*n];5delay(1);}}}}}voiddelay(unsignedinti){unsignedintx,y;for(x=i;x0;x--)for(y=110;y0;y--);}实验4点阵与键盘实验#defineLED_Y(*(volatileunsignedshort*)0x80001000)#defineKEY_x(*(volatileunsignedchar*)0x38001002)#defineGPFCON(*(volatileunsignedshort*)0x56000050)#defineGPFDAT(*(volatileunsignedchar*)0x56000054)//GPFDAT0(0表示0x56000054地址的第0位)列地址第一位,GPFDAT3(3表示0x56000054地址的第三位)列地址第二位#defineGPFUP(*(volatileunsignedchar*)0x56000058)#defineGPGCON(*(volatileunsignedint*)0x56000060)#defineGPGDAT(*(volatileunsignedshort*)0x56000064)//GPGDAT3(3表示0x56000064地址的第三位)列地址第三位,GPGDAT11(11表示0x56000064地址的第11位)列地址第4位#defineGPGUP(*(volatileunsignedshort*)0x56000068)unsignedshortZM[]={0x00fe,0x18fd,0x24fb,0x24f7,0x24ef,0x24df,0x18bf,0x007f,//00x18fe,0x1cfd,0x10fb,0x10f7,0x10ef,0x10df,0x7cbf,0x007f,//10x38fe,0x44fd,0x20FB,0x10F7,0x08EF,0x04DF,0x7cBF,0X007F,//20x38fe,0x44fd,0x20fb,0x10f7,0x20ef,0x44df,0x38bf,0x007f,//30x28fe,0x28fd,0x28fb,0x24f7,0x22ef,0x7edf,0x20bf,0x207f,//40x3cfe,0x04fd,0x04FB,0x3cF7,0x40EF,0x40DF,0x44BF,0X387F,//50x10fe,0x08fd,0x04fb,0x1ef7,0x22ef,0x22df,0x22bf,0x1c7f,//60x3efe,0x20fd,0x10fb,0x08f7,0x08ef,0x08df,0x08bf,0x087f,//70x3cfe,0x42fd,0x42FB,0x3cF7,0x42EF,0x42DF,0x42BF,0X3c7F,//80x38fe,0x44fd,0x44fb,0x44f7,0x38ef,0x20df,0x10bf,0x087f,//9/*0x00fe,0x32fd,0x4afb,0x4af7,0x4aef,0x4adf,0x32bf,0x007f,//100x00fe,0x24fd,0x24FB,0x24F7,0x24EF,0x24DF,0x24BF,0X007F,//110x00fe,0x32fd,0x4afb,0x22f7,0x12ef,0x0adf,0x7abf,0x007f,//120x32fe,0x4afd,0x42FB,0x32F7,0x42EF,0x4aDF,0x32BF,0X007F,//130x52fe,0x52fd,0x52fb,0x4af7,0xfaef,0x42df,0x42bf,0x007f,//140x3afe,0x0afd,0x0afb,0x3af7,0x42ef,0x4adf,0x32bf,0x007f,//150x22fe,0x12fd,0x0aFB,0x3aF7,0x4aEF,0x4aDF,0x32BF,0X007F,//16*/60x1cfe,0x22fd,0x22FB,0x3eF7,0x22EF,0x2

1 / 12
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功