DSP设计科学计算器实验报告

上传人:206****923 文档编号:91566096 上传时间:2019-06-29 格式:DOCX 页数:7 大小:22.77KB
返回 下载 相关 举报
DSP设计科学计算器实验报告_第1页
第1页 / 共7页
DSP设计科学计算器实验报告_第2页
第2页 / 共7页
DSP设计科学计算器实验报告_第3页
第3页 / 共7页
DSP设计科学计算器实验报告_第4页
第4页 / 共7页
DSP设计科学计算器实验报告_第5页
第5页 / 共7页
点击查看更多>>
资源描述

《DSP设计科学计算器实验报告》由会员分享,可在线阅读,更多相关《DSP设计科学计算器实验报告(7页珍藏版)》请在金锄头文库上搜索。

1、基于DSP的科学型计算器设计一、题目要求:基于DSP F2812利用实验箱及软件编程设计一款科学型计算器使其满足如下功能:(1) 能够实现按键数值的识别,并在数码管上显示(2) 能够进行简单的加减运算(3) 能够进行小数运算二、思路设计 1、TMS320X2812实验箱资源功能简介:采用TMS320X2812片上的GPIOA及GPIOB作为IO口接受实验箱上的按键值进行判断。同时设置两个IO口进行循环0,1发送给row1,row2实现键盘扫描,从而实现识别k11k23的值。将箱上的k1k8,k11k23作为计算器键盘。k1k8为07,k11为8,k12为9,k13为清零键,k21为“=”键,k

2、22为+,k23为-。三、综合设计的程序分析LED显示过程循环扫描进入模块键值输入 程序框图#include DSP28_Device.h引脚定义:#define Key1GpioDataRegs.GPADAT.bit.GPIOA0 / 0#define Key2 GpioDataRegs.GPADAT.bit.GPIOA1 / 1#define Key3 GpioDataRegs.GPADAT.bit.GPIOA2 / 2#define Key4 GpioDataRegs.GPADAT.bit.GPIOA3 / 3 #define Key5 GpioDataRegs.GPADAT.bit.G

3、PIOA4 / 4#define Key6 GpioDataRegs.GPADAT.bit.GPIOA5 / 5#define Key7 GpioDataRegs.GPADAT.bit.GPIOA8 / 6#define Key8 GpioDataRegs.GPADAT.bit.GPIOA9 / 7*/#define row1 GpioDataRegs.GPBDAT.bit.GPIOB0 /PWM7 #define col1 GpioDataRegs.GPBDAT.bit.GPIOB1 /PWM8 #define row2 GpioDataRegs.GPBDAT.bit.GPIOB2 /PWM

4、9 #define col2 GpioDataRegs.GPBDAT.bit.GPIOB3 /PWM10#define col3 GpioDataRegs.GPBDAT.bit.GPIOB4 /PWM11 /*k1k8,k11k23作为计算器键盘。k1k8为07,k11为8,k12为9,k13为清零键,k21为“=”键,k22为+,k23为-#define Add 0x0A#define Sub 0x0B#define Clear 0x0C#define multi 0x04#define divi 0x08#define dot 0x0Dunsigned char ScanKey(void)

5、;int num(void);unsigned int Enter(void);int ifdot(void);/Relative to spi_receive,not use rightnowunsigned int Spi_VarRx100;unsigned int i,j,key;extern unsigned int Int_Flag;主函数如下:void main(void) unsigned int countnum,shownum, countnum1, countnum2,count=0,co,step=1,math=0;int noun=-1,dot1=0; countnum

6、 = 0;countnum1 = 0;countnum2 = 0;co=0; while(1) noun=num();/键值 key=ScanKey(); dot1=ifdot(); if(key!=0)noun=key; /输入第一个数 if(noun=0&noun=9) if(dot1=0) if(step=1) if(count4) count+; countnum1= noun+countnum1*10; else count=0;countnum1=0; countnum=countnum1; shownum = BIN2BCD(countnum); ShowBCD(shownum)

7、; else if(step=2) if(count4) count+; countnum2= noun+countnum2*10; else count=0;countnum2=0; shownum = BIN2BCD(countnum2); ShowBCD(shownum); if(dot1=1) if(step=1) if(count4) count+; countnum1= noun+countnum1*10; else count=0;countnum1=0; countnum=countnum1; shownum = BIN2BCD(countnum); ShowBCD1(show

8、num); else if(step=2) if(count4) count+; countnum2= noun+countnum2*10; else count=0;countnum2=0; shownum = BIN2BCD(countnum2); ShowBCD1(shownum); if(noun=Add) step=2;count=0; math=1; else if(noun=Sub) step=2;count=0; math=2; else if(noun=Clear) countnum=0;step=1; countnum1=0; countnum2=0; math=0; co

9、unt=0; noun=-1; shownum = BIN2BCD(countnum); ShowBCD(shownum); else if(Enter()=1) switch (math) case 1:countnum=countnum1+countnum2;break; case 2:countnum=countnum1-countnum2;break; default:break; shownum = BIN2BCD(countnum); ShowBCD(shownum); math=0; countnum1=0;countnum2=0; step=1; /K11至K23的按键原理图如

10、下(键盘扫描): 等于按键分配函数如下:unsigned int Enter(void) unsigned int k11,k12,k13,k21,k22,k23; unsigned int c10,c20,c30,c21,c11,c31; k11=0;k12=0;k13=0;k21=0;k22=0;k23=0; GpioDataRegs.GPBDAT.bit.GPIOB2=1;/row2 GpioDataRegs.GPBDAT.bit.GPIOB0=0;/row1 c10=col1; c20=col2;c30=col3; GpioDataRegs.GPBDAT.bit.GPIOB2=0;/r

11、ow2 GpioDataRegs.GPBDAT.bit.GPIOB0=1;/row1 c11=col1; c21=col2;c31=col3; if(c11=0 & c10=1)k21=1; if(k21)return 1; else return 0; 分配加、减、清零及小数点的按键 :unsigned char ScanKey(void) unsigned int k11,k12,k13,k21,k22,k23; unsigned int c10,c20,c30,c21,c11,c31; k11=0;k21=0;k12=0;k22=0;k21=0;k23=0;k13=0; GpioData

12、Regs.GPBDAT.bit.GPIOB2=1;/row2 GpioDataRegs.GPBDAT.bit.GPIOB0=0;/row1 c10=col1; c20=col2;c30=col3; GpioDataRegs.GPBDAT.bit.GPIOB2=0;/row2 GpioDataRegs.GPBDAT.bit.GPIOB0=1;/row1 c11=col1; c21=col2;c31=col3; if(c21=0 & c20=1)k22 =1; if(c21=1 & c20=0)k12 =1; if(c31=0 & c30=1)k23 =1; if(c31=1 & c30=0)k13 =1; if(k22=1)KeyData=Add; else if(k

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 中学教育 > 其它中学文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号