嵌入式实验报告,各实验答案
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Delay(200);
}
for (i =1; i <7; i++)
{
LED_CS4 = (LED_VALUE >> i) +1;
Delay(200);
}
}
}
实验总结:
数码管显示实验报告
实验目的
1.在实验一引导程序的基础上进一步了解ARM体系结构和编程方法;
2.掌握外设访问的方法;
3.理解8段数码管的显示原理
#define LED_CS3(*((volatile unsigned short int *)(0x10400000)))//LED3 and LED4
#define LED_CS4(*((volatile unsigned char *)(0x10500000)))
#define LED_VALUE (0xff)
Delay(200);
}
}
}
2、从左到右,再从右到左灯灭,不断循环
#define LED_CS4(*((volatile unsigned char *)(0x10500000)))
#define LED_VALUE (0xff)
int i;
void Delay(unsigned int x)
{
unsigned int i, j, k;
}
for (i = 7; i >= 4; i--)
{
LED_CS4 = (LED_VALUE << i) -1;
Delay(200);
}
}
}
3、从左到右,从右到左,隔一个跳
#define LED_CS4(*((volatile unsigned char *)(0x10500000)))
#define LED_VALUE (0xff)
#define LED_CS3(*((volatile unsigned short int *)(0x10400000)))//LED3 and LED4
#define KPDK_VALUE(*((volatileunsigned char *)(0x41500008)))//Direct Keypad
void Delay(unsigned int x)
{
unsigned int i, j, k;
for (i =0; i <=x; i++)
for (j = 0; j <0xff; j++)
for (k = 0; k <0xff; k++);
}
int i = 0;
void dummyOs(void)
LED_CS3 = 0x8F8F;
LED_CS4 = 0x6F;
break;
case 0x11://key-press 10
kbd_buff=0x088F;
LED_CS2 = kbd_buff;
LED_CS3 = 0x8F8F;
LED_CS4 = 0xAF;
break;
case 0x05://key-press 8
kbd_buff=0x008F;
LED_CS3 = kbd_buff;
LED_CS2 = 0x8F8F;
LED_CS4 = 0xEF;
break;
case 0x10://key-press 9
kbd_buff=0x8F18;
LED_CS2 = kbd_buff;
3.掌握键盘输入的编程方法
实验要求:
1.对所有16个按键进行编码,如使用一位数字[0-F,也可以用两位]
2.当按键后,在七段数码管上显示对应的键盘编码。
3.在跑码灯上显示相应二进制数。
实验代码:
#include <stdio.h>
#include "register_variant.h"
#define LED_CS2(*((volatile unsigned short int *)(0x10300000)))//LED1 and LED2
default: kbd_buffFra Baidu bibliotek0x8F8F; break;
}
switch (n)
{
case 0x00://key-press 5
kbd_buff=0x8F12;
LED_CS2 = kbd_buff;
LED_CS3 = 0x8F8F;
LED_CS4 = 0x5F;
break;
case 0x01://key-press 6
for (i =0; i <=x; i++)
for (j = 0; j <0xff; j++)
for (k = 0; k <0xff; k++);
}
void dummyOs(void)
{
while (1)
{
LED_CS4 = 0x00;
for (i = 8; i >=1; i--)
{
LED_CS4 = (LED_VALUE >> i) +1;
boot实验报告
本次实验由于时间限制,共完成了三种不同的变化方式,但是课后又设计了一些其他的变化方式。
1、从左到右,再从右到左亮灯,不断循环
#define LED_CS4(*((volatile unsigned char *)(0x10500000)))
#define LED_VALUE (0xff)
LED_CS3 = kbd_buff;
LED_CS2 = 0x8F8F;
LED_CS4 = 0x3F;
break;
case 0x20://key-press 4
kbd_buff=0x198F;
LED_CS3 = kbd_buff;
LED_CS2 = 0x8F8F;
LED_CS4 = 0xDF;
break;
LED_CS4 = 0x7F;
break;
case 0x02://key-press 2
kbd_buff=0x248F;
LED_CS2 = kbd_buff;
LED_CS3 = 0x8F8F;
LED_CS4 = 0xBF;
break;
case 0x04://key-press 3
kbd_buff=0x8F30;
#define LED_CS4(*((volatile unsigned char *)(0x10500000)))
#define LED_VALUE (0xff)
int i;
void Delay(unsigned int x)
{
unsigned int i, j, k;
for (i =0; i <=x; i++)
else i = 0;
Delay(200);
LED_CS2 = 0x4024; //2 0
LED_CS3 = 0x3030; //3 3
LED_CS4 = (LED_VALUE << i) -1;
if(i <= 8) i++;
else i = 0;
Delay(200);
LED_CS2 = 0x4024; //2 0
char m = 0, n = 0;
unsigned short int kbd_buff;
m = KPDK_VALUE ;
n = KAPS_VALUE ;
switch (m)
{
case 0x40://key-press 1
kbd_buff=0x8F79;
LED_CS2 = kbd_buff;
LED_CS3 = 0x8F8F;
LED_CS3 = 0x2430; //3 2
LED_CS4 = (LED_VALUE << i) -1;
if(i <= 8) i++;
else i = 0;
Delay(200);
LED_CS2 = 0x4024; //2 0
LED_CS3 = 0x3030; //3 3
LED_CS4 = (LED_VALUE << i) -1;
int i;
void Delay(unsigned int x)
{
unsigned int i, j, k;
for (i =0; i <=x; i++)
for (j = 0; j <0xff; j++)
for (k = 0; k <0xff; k++);
}
void dummyOs(void)
{
while (1)
kbd_buff=0x028F;
LED_CS2 = kbd_buff;
LED_CS3 = 0x8F8F;
LED_CS4 = 0x9F;
break;
case 0x02://key-press 7
kbd_buff=0x8F78;
LED_CS3 = kbd_buff;
LED_CS2 = 0x8F8F;
LED_CS4 = 0x1F;
{
LED_CS4 = 0xff;
for (i = 1; i <8; i=i+2)
{
LED_CS4 = (LED_VALUE << i) -1;
Delay(200);
}
for (i = 7; i > 1; i=i-2)
{
LED_CS4 = (LED_VALUE << i) -1;
Delay(200);
if(i <= 8) i++;
else i = 0;
Delay(200);
LED_CS2 = 0x0308; //A b
LED_CS3 = 0x0646; //C E
LED_CS4 = (LED_VALUE << i) -1;
if(i <= 8) i++;
else i = 0;
Delay(200);
#define KAPS_VALUE (*((volatile unsigned char *)(0x41500020)))
#define LED_CS4(*((volatile unsigned char *)(0x10500000)))
void button_statusFetch(void)
{
实验内容
1 显示同组的两位同学的四位学号2032 2033;
2 显示一组大于九的四位十六进制数字,如abcd。
3 使跑码灯从左到右顺序亮。
实验代码
#include <stdio.h>
#include "register_variant.h"
#define LED_CS2(*((volatile unsigned short int *)(0x10300000)))//LED1 and LED2
for (j = 0; j <0xff; j++)
for (k = 0; k <0xff; k++);
}
void dummyOs(void)
{
while (1)
{
LED_CS4 = 0xff;
for (i = 0; i <4; i++)
{
LED_CS4 = (LED_VALUE << i) -1;
Delay(200);
{
LED_CS2 = 0x8f8f; //0 0
LED_CS3 = 0x8f8f; //0 0
while(1)
{
//Delay(100);
LED_CS2 = 0x4024; //2 0
LED_CS3 = 0x2430; //3 2
LED_CS4 = (LED_VALUE << i) -1;
if(i <= 8) i++;
for (i =0; i <=x; i++)
for (j = 0; j <0xff; j++)
for (k = 0; k <0xff; k++);
}
void dummyOs(void)
{
while (1)
{
LED_CS4 = 0x00;
for (i = 8; i >=1; i--)
{
LED_CS4 = (LED_VALUE >> i) +1;
{
LED_CS4 = 0xff;
for (i =1; i <=8; i++)
{
LED_CS4 = (LED_VALUE << i) -1;
Delay(200);
}
for (i =7; i >1; i--)
{
LED_CS4 = (LED_VALUE << i) -1;
Delay(200);
}
}
}
2、先从左到中,后从右到中,不断循环
}
}
}
课后补做:
1、从左到右灯灭
#define LED_CS4(*((volatile unsigned char *)(0x10500000)))
#define LED_VALUE (0xff)
int i;
void Delay(unsigned int x)
{
unsigned int i, j, k;
int i;
void Delay(unsigned int x)
{
unsigned int i, j, k;
for (i =0; i <=x; i++)
for (j = 0; j <0xff; j++)
for (k = 0; k <0xff; k++);
}
void dummyOs(void)
{
while (1)
LED_CS2 = 0x0308; //A b
LED_CS3 = 0x0646; //C E
LED_CS4 = (LED_VALUE << i) -1;
if(i <= 8) i++;
else i = 0;
Delay(200);
}
}
实验总结:
键盘实验实验报告
实验目的:
1.了解直入键盘与矩阵键盘的原理
2.了解键盘寄存器的功能
}
for (i =1; i <7; i++)
{
LED_CS4 = (LED_VALUE >> i) +1;
Delay(200);
}
}
}
实验总结:
数码管显示实验报告
实验目的
1.在实验一引导程序的基础上进一步了解ARM体系结构和编程方法;
2.掌握外设访问的方法;
3.理解8段数码管的显示原理
#define LED_CS3(*((volatile unsigned short int *)(0x10400000)))//LED3 and LED4
#define LED_CS4(*((volatile unsigned char *)(0x10500000)))
#define LED_VALUE (0xff)
Delay(200);
}
}
}
2、从左到右,再从右到左灯灭,不断循环
#define LED_CS4(*((volatile unsigned char *)(0x10500000)))
#define LED_VALUE (0xff)
int i;
void Delay(unsigned int x)
{
unsigned int i, j, k;
}
for (i = 7; i >= 4; i--)
{
LED_CS4 = (LED_VALUE << i) -1;
Delay(200);
}
}
}
3、从左到右,从右到左,隔一个跳
#define LED_CS4(*((volatile unsigned char *)(0x10500000)))
#define LED_VALUE (0xff)
#define LED_CS3(*((volatile unsigned short int *)(0x10400000)))//LED3 and LED4
#define KPDK_VALUE(*((volatileunsigned char *)(0x41500008)))//Direct Keypad
void Delay(unsigned int x)
{
unsigned int i, j, k;
for (i =0; i <=x; i++)
for (j = 0; j <0xff; j++)
for (k = 0; k <0xff; k++);
}
int i = 0;
void dummyOs(void)
LED_CS3 = 0x8F8F;
LED_CS4 = 0x6F;
break;
case 0x11://key-press 10
kbd_buff=0x088F;
LED_CS2 = kbd_buff;
LED_CS3 = 0x8F8F;
LED_CS4 = 0xAF;
break;
case 0x05://key-press 8
kbd_buff=0x008F;
LED_CS3 = kbd_buff;
LED_CS2 = 0x8F8F;
LED_CS4 = 0xEF;
break;
case 0x10://key-press 9
kbd_buff=0x8F18;
LED_CS2 = kbd_buff;
3.掌握键盘输入的编程方法
实验要求:
1.对所有16个按键进行编码,如使用一位数字[0-F,也可以用两位]
2.当按键后,在七段数码管上显示对应的键盘编码。
3.在跑码灯上显示相应二进制数。
实验代码:
#include <stdio.h>
#include "register_variant.h"
#define LED_CS2(*((volatile unsigned short int *)(0x10300000)))//LED1 and LED2
default: kbd_buffFra Baidu bibliotek0x8F8F; break;
}
switch (n)
{
case 0x00://key-press 5
kbd_buff=0x8F12;
LED_CS2 = kbd_buff;
LED_CS3 = 0x8F8F;
LED_CS4 = 0x5F;
break;
case 0x01://key-press 6
for (i =0; i <=x; i++)
for (j = 0; j <0xff; j++)
for (k = 0; k <0xff; k++);
}
void dummyOs(void)
{
while (1)
{
LED_CS4 = 0x00;
for (i = 8; i >=1; i--)
{
LED_CS4 = (LED_VALUE >> i) +1;
boot实验报告
本次实验由于时间限制,共完成了三种不同的变化方式,但是课后又设计了一些其他的变化方式。
1、从左到右,再从右到左亮灯,不断循环
#define LED_CS4(*((volatile unsigned char *)(0x10500000)))
#define LED_VALUE (0xff)
LED_CS3 = kbd_buff;
LED_CS2 = 0x8F8F;
LED_CS4 = 0x3F;
break;
case 0x20://key-press 4
kbd_buff=0x198F;
LED_CS3 = kbd_buff;
LED_CS2 = 0x8F8F;
LED_CS4 = 0xDF;
break;
LED_CS4 = 0x7F;
break;
case 0x02://key-press 2
kbd_buff=0x248F;
LED_CS2 = kbd_buff;
LED_CS3 = 0x8F8F;
LED_CS4 = 0xBF;
break;
case 0x04://key-press 3
kbd_buff=0x8F30;
#define LED_CS4(*((volatile unsigned char *)(0x10500000)))
#define LED_VALUE (0xff)
int i;
void Delay(unsigned int x)
{
unsigned int i, j, k;
for (i =0; i <=x; i++)
else i = 0;
Delay(200);
LED_CS2 = 0x4024; //2 0
LED_CS3 = 0x3030; //3 3
LED_CS4 = (LED_VALUE << i) -1;
if(i <= 8) i++;
else i = 0;
Delay(200);
LED_CS2 = 0x4024; //2 0
char m = 0, n = 0;
unsigned short int kbd_buff;
m = KPDK_VALUE ;
n = KAPS_VALUE ;
switch (m)
{
case 0x40://key-press 1
kbd_buff=0x8F79;
LED_CS2 = kbd_buff;
LED_CS3 = 0x8F8F;
LED_CS3 = 0x2430; //3 2
LED_CS4 = (LED_VALUE << i) -1;
if(i <= 8) i++;
else i = 0;
Delay(200);
LED_CS2 = 0x4024; //2 0
LED_CS3 = 0x3030; //3 3
LED_CS4 = (LED_VALUE << i) -1;
int i;
void Delay(unsigned int x)
{
unsigned int i, j, k;
for (i =0; i <=x; i++)
for (j = 0; j <0xff; j++)
for (k = 0; k <0xff; k++);
}
void dummyOs(void)
{
while (1)
kbd_buff=0x028F;
LED_CS2 = kbd_buff;
LED_CS3 = 0x8F8F;
LED_CS4 = 0x9F;
break;
case 0x02://key-press 7
kbd_buff=0x8F78;
LED_CS3 = kbd_buff;
LED_CS2 = 0x8F8F;
LED_CS4 = 0x1F;
{
LED_CS4 = 0xff;
for (i = 1; i <8; i=i+2)
{
LED_CS4 = (LED_VALUE << i) -1;
Delay(200);
}
for (i = 7; i > 1; i=i-2)
{
LED_CS4 = (LED_VALUE << i) -1;
Delay(200);
if(i <= 8) i++;
else i = 0;
Delay(200);
LED_CS2 = 0x0308; //A b
LED_CS3 = 0x0646; //C E
LED_CS4 = (LED_VALUE << i) -1;
if(i <= 8) i++;
else i = 0;
Delay(200);
#define KAPS_VALUE (*((volatile unsigned char *)(0x41500020)))
#define LED_CS4(*((volatile unsigned char *)(0x10500000)))
void button_statusFetch(void)
{
实验内容
1 显示同组的两位同学的四位学号2032 2033;
2 显示一组大于九的四位十六进制数字,如abcd。
3 使跑码灯从左到右顺序亮。
实验代码
#include <stdio.h>
#include "register_variant.h"
#define LED_CS2(*((volatile unsigned short int *)(0x10300000)))//LED1 and LED2
for (j = 0; j <0xff; j++)
for (k = 0; k <0xff; k++);
}
void dummyOs(void)
{
while (1)
{
LED_CS4 = 0xff;
for (i = 0; i <4; i++)
{
LED_CS4 = (LED_VALUE << i) -1;
Delay(200);
{
LED_CS2 = 0x8f8f; //0 0
LED_CS3 = 0x8f8f; //0 0
while(1)
{
//Delay(100);
LED_CS2 = 0x4024; //2 0
LED_CS3 = 0x2430; //3 2
LED_CS4 = (LED_VALUE << i) -1;
if(i <= 8) i++;
for (i =0; i <=x; i++)
for (j = 0; j <0xff; j++)
for (k = 0; k <0xff; k++);
}
void dummyOs(void)
{
while (1)
{
LED_CS4 = 0x00;
for (i = 8; i >=1; i--)
{
LED_CS4 = (LED_VALUE >> i) +1;
{
LED_CS4 = 0xff;
for (i =1; i <=8; i++)
{
LED_CS4 = (LED_VALUE << i) -1;
Delay(200);
}
for (i =7; i >1; i--)
{
LED_CS4 = (LED_VALUE << i) -1;
Delay(200);
}
}
}
2、先从左到中,后从右到中,不断循环
}
}
}
课后补做:
1、从左到右灯灭
#define LED_CS4(*((volatile unsigned char *)(0x10500000)))
#define LED_VALUE (0xff)
int i;
void Delay(unsigned int x)
{
unsigned int i, j, k;
int i;
void Delay(unsigned int x)
{
unsigned int i, j, k;
for (i =0; i <=x; i++)
for (j = 0; j <0xff; j++)
for (k = 0; k <0xff; k++);
}
void dummyOs(void)
{
while (1)
LED_CS2 = 0x0308; //A b
LED_CS3 = 0x0646; //C E
LED_CS4 = (LED_VALUE << i) -1;
if(i <= 8) i++;
else i = 0;
Delay(200);
}
}
实验总结:
键盘实验实验报告
实验目的:
1.了解直入键盘与矩阵键盘的原理
2.了解键盘寄存器的功能