版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、精選優(yōu)質(zhì)文檔-傾情為你奉上基于DSP的科學(xué)型計(jì)算器設(shè)計(jì)一、題目要求:基于DSP F2812利用實(shí)驗(yàn)箱及軟件編程設(shè)計(jì)一款科學(xué)型計(jì)算器使其滿足如下功能:(1) 能夠?qū)崿F(xiàn)按鍵數(shù)值的識(shí)別,并在數(shù)碼管上顯示(2) 能夠進(jìn)行簡(jiǎn)單的加減運(yùn)算(3) 能夠進(jìn)行小數(shù)運(yùn)算二、思路設(shè)計(jì) 1、TMS320X2812實(shí)驗(yàn)箱資源功能簡(jiǎn)介:采用TMS320X2812片上的GPIOA及GPIOB作為IO口接受實(shí)驗(yàn)箱上的按鍵值進(jìn)行判斷。同時(shí)設(shè)置兩個(gè)IO口進(jìn)行循環(huán)0,1發(fā)送給row1,row2實(shí)現(xiàn)鍵盤掃描,從而實(shí)現(xiàn)識(shí)別k11k23的值。將箱上的k1k8,k11k23作為計(jì)算器鍵盤。k1k8為07,k11為8,k12為9,k13為清
2、零鍵,k21為“=”鍵,k22為+,k23為-。三、綜合設(shè)計(jì)的程序分析LED顯示過程循環(huán)掃描進(jìn)入模塊鍵值輸入 程序框圖#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
3、GpioDataRegs.GPADAT.bit.GPIOA4 / 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 GpioDataRe
4、gs.GPBDAT.bit.GPIOB2 /PWM9 #define col2 GpioDataRegs.GPBDAT.bit.GPIOB3 /PWM10#define col3 GpioDataRegs.GPBDAT.bit.GPIOB4 /PWM11 /*k1k8,k11k23作為計(jì)算器鍵盤。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 0x0Dun
5、signed char ScanKey(void);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;主函數(shù)如下:void main(void) unsigned int countnum,shownum, countnum1, countnum2,count=0,co,step=1,math=0;int
6、 noun=-1,dot1=0; countnum = 0;countnum1 = 0;countnum2 = 0;co=0; while(1) noun=num();/鍵值 key=ScanKey(); dot1=ifdot(); if(key!=0)noun=key; /輸入第一個(gè)數(shù) if(noun>=0&&noun<=9) if(dot1=0) if(step=1) if(count<4) count+; countnum1= noun+countnum1*10; else count=0;countnum1=0; countnum=countnum1;
7、 shownum = BIN2BCD(countnum); ShowBCD(shownum); else if(step=2) if(count<4) count+; countnum2= noun+countnum2*10; else count=0;countnum2=0; shownum = BIN2BCD(countnum2); ShowBCD(shownum); if(dot1=1) if(step=1) if(count<4) count+; countnum1= noun+countnum1*10; else count=0;countnum1=0; countnum
8、=countnum1; shownum = BIN2BCD(countnum); ShowBCD1(shownum); else if(step=2) if(count<4) 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=Clea
9、r) countnum=0;step=1; countnum1=0; countnum2=0; math=0; count=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)
10、; math=0; countnum1=0;countnum2=0; step=1; /K11至K23的按鍵原理圖如下(鍵盤掃描): "等于"按鍵分配函數(shù)如下: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;
11、/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(c11=0 & c10=1)k21=1; if(k21)return 1; else return 0; 分配加、減、清零及小數(shù)點(diǎn)的按鍵 :unsigned char ScanKey(void) unsigned int k11,k12,k13,k21,k22,k23; unsigned int c1
12、0,c20,c30,c21,c11,c31; k11=0;k21=0;k12=0;k22=0;k21=0;k23=0;k13=0; GpioDataRegs.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
13、)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(k23=1)KeyData=Sub; else if(k13=1)KeyData=Clear; else if(k12=1)KeyData=dot; else KeyData=0; return(KeyData); 分配07數(shù)字按鍵:int num(void) int x; unsigned int c10,c20,c30,k; unsigned
14、 int c11,c21,c31; unsigned int k11,k12,k13,k21,k22,k23; 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;/row2 GpioDataRegs.GPBDAT.bit.GPIOB0=1;/row1 c11=col1; c21=col2;c31
15、=col3; if(c11=1 & c10=0)k11=1; if(Key1=0)x=0; else if(Key2=0)x=1; else if(Key3=0)x= 2; else if(Key4=0)x= 3; else if(Key5=0)x=4; else if(Key6=0)x=5; else if(Key7=0)x=6; else if(Key8=0)x=7; else if(k11)x=8; else x=-1; return x; 分配小數(shù)點(diǎn)按鍵:int ifdot(void) int x; unsigned int c10,c20,c30,k; unsigned int c11,c21,c31; unsigned int k11,k12,k13,k21,k22,k23; k11=0;k12=0;k13=0;k21=0;k22=0;k23=0; for(k=0;k<2;k+) GpioDataRegs.GPBDAT.bit.GPIOB2=1;/row2 Gpio
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五年度學(xué)校教師學(xué)生國(guó)際交流與合作聘用合同3篇
- 二零二五年度信息技術(shù)產(chǎn)品軟件售后服務(wù)合同書模板2篇
- 2025年度個(gè)人法律咨詢委托書范本4篇
- 二零二五年度廚房電氣設(shè)備安裝與維護(hù)承包協(xié)議4篇
- 2025版實(shí)習(xí)合同模板:實(shí)習(xí)期間解約與補(bǔ)償3篇
- 二零二五版舊機(jī)動(dòng)車交易車輛售后配件供應(yīng)合同3篇
- 2025版實(shí)習(xí)期員工勞動(dòng)合同-實(shí)習(xí)期間合同解除與續(xù)簽3篇
- 二零二五年度商業(yè)寫字樓租賃合同樣本
- 二零二五年度外語翻譯公司兼職外教資源合作與管理合同
- 2025版投資框架協(xié)議模板下載與投資法律法規(guī)咨詢3篇
- 反騷擾政策程序
- 運(yùn)動(dòng)技能學(xué)習(xí)與控制課件第十一章運(yùn)動(dòng)技能的練習(xí)
- 射頻在疼痛治療中的應(yīng)用
- 四年級(jí)數(shù)學(xué)豎式計(jì)算100道文檔
- “新零售”模式下生鮮電商的營(yíng)銷策略研究-以盒馬鮮生為例
- 項(xiàng)痹病辨證施護(hù)
- 職業(yè)安全健康工作總結(jié)(2篇)
- 懷化市數(shù)字經(jīng)濟(jì)產(chǎn)業(yè)發(fā)展概況及未來投資可行性研究報(bào)告
- 07FD02 防空地下室電氣設(shè)備安裝
- 教師高中化學(xué)大單元教學(xué)培訓(xùn)心得體會(huì)
- 彈簧分離問題經(jīng)典題目
評(píng)論
0/150
提交評(píng)論