欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    嵌入式课程设计电子词典硬件设计.doc

    • 资源ID:50920341       资源大小:557.48KB        全文页数:30页
    • 资源格式: DOC        下载积分:20金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要20金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    嵌入式课程设计电子词典硬件设计.doc

    上海电力学院嵌入式系统课程设计报告题目: 电子词典的设计 姓 名: 学 号: 院系: 专业年级: 同组成员: 年月日一、实验内容及要求在LCD屏幕左侧绘制出单词输入框和释义显示框以及一个搜索键,右侧绘制4*4键盘按钮,模拟出简易电子词典的功能,按钮操作用触摸屏或键盘实现均可。实现功能:(1)LCD屏幕上显示4*4键盘,显示单词及其翻译、例句。(2)一个键可完成2个英文字母的输入,如左上角第一个键可实现输入a,b两个字母,第一次按下时为输入a,如果需输入b,只需连续快速按键两次即可。(3)在输入完单词后,点击搜索键,即可在释义显示框中显示该单词的词性、中文解释、示例词组和句子等。(4)当发现输入的单词在库中不存在时,可实现将该单词添加入库的操作。二、设计思路(1)通过LCD显示模块画出电子词典操作界面。(2)对应界面中各键的位置设置键盘对应键值。(3)设定功能键,实现以下3个功能:退格键:删除最后一位字母;搜索保存键:对输入框的单词进行判断,若单词存在于词库中,则显示单词词性、词义、例句;若单词不存在则自动进行保存;转换键:按下后,字母键输出对应的第二个字母。(4)按键后赋值并显示。三、软件构架开始LCD模块键盘模块结束四、模块分析(1)键盘模块流程图:开始键盘初始化键盘是否按下Y读取键值是否是功能键YN执行功能赋值显示结束N源代码:/* File:keyboard.c* Author:embest* Desc:keyboard source code* History:*/*- include files -*/#include "44b.h"#include "44blib.h"#include "def.h"#include "keyboard.h"#include "lcd.h"#include "dict.h"#ifndef KEY_INT#define KEY_INT#endif#ifndef BUT_INT#define BUT_INT#endif/*- global variables -*/int input_char,n=0;char word20;int wordIndex=0;int x = 15;int num=0;int counter=0;/* keyboard control address */volatile UCHAR *keyboard_base = (UCHAR *)0x06000000;/*- function declare -*/void init_keyboard();void close_keyboard();void KeyboardInt(void);/ _attribute_ (interrupt ("IRQ");void Eint4567Isr(void);/ _attribute_ (interrupt ("IRQ");/*- function code -*/* name:Test_Keyboard* func:test keyboard* para:none* ret:none* modify:* comment:*/void Test_Keyboard()Uart_Printf("n Keyboard Test Examplen");Uart_Printf("n Please press one key on keyboard and look at LED .n");/ init keyboardinit_keyboard();while(1);/ close keyboard/ close_keyboard();/* name:init_keyboard* func:init keyboard interrupt* para:none* ret:none* modify:* comment:*/extern void isrEINT1(void);extern void isrEint4567(void);void init_keyboard()/* enable interrupt */rINTMOD = 0x0;rINTCON = 0x1;/* set EINT1 interrupt handler */rINTMSK =(BIT_GLOBAL|BIT_EINT1|BIT_EINT4567); pISR_EINT1 = (int)isrEINT1; pISR_EINT4567 = (int)isrEint4567; /* PORT G */ rPCONG = 0xffff;/ EINT70rPUPG = 0x0;/ pull up enable rEXTINT = rEXTINT|0x20;/ EINT1 falling edge moderI_ISPC = BIT_EINT1|BIT_EINT4567;/ clear pending bitrEXTINTPND = 0xf;/ clear EXTINTPND reg/* name:close_keyboard* func:close keyboard interrupt* para:none* ret:none* modify:* comment:*/void close_keyboard()pISR_EINT1 = NULL;pISR_EINT4567 = NULL;/* Mask interrupt */rINTMSK = rINTMSK | BIT_EINT1 | BIT_EINT4567;/* name:KeyboardInt* func:keyboard interrupt handler function* para:none* ret:none* modify:* comment:*/void KeyboardInt(void)int nTemp,i,j,k,m=0;char bbyte;rI_ISPC = BIT_EINT1;/ clear pending bitchar pbyte10;nTemp = key_read();if(nTemp > -1) / Lcd_Draw_HLine(10, 310, 80, WHITE, 50);input_char = nTemp;Lcd_DspAscII8x16(15,45,WHITE,word);switch(input_char) case 0: num=1;break; case 1: num=2;break; case 2: num=3;break; case 3: num=4;break; case 4: num=5;break; case 5: num=6;break; case 6: num=7;break; case 7: num=8;break; case 8: num=9;break; case 9: counter=1;break; case 10: counter=2;break; case 11: counter=3;break; case 12: m=1; Lcd_Draw_HLine(15+n-10, 15+n, 45, WHITE, 16); n-=10; wordwordIndex='0' wordIndex-; break; /*if(n=0) word20=0; wordIndex=0; Lcd_Draw_HLine(10, 310,85, WHITE, 160); break;*/ case 13: wordwordIndex='0' wordIndex=0; for(i=0;i<20;i+) if(strcmp(word,vocabi.c)=0) j=0; k=i; break; else j=1; if(j=0) /#ifdef Eng_v Lcd_DspAscII8x16(15,40,BLUE,vocabk.c);Lcd_DspAscII8x16(15,60,BLUE,vocabk.d);Lcd_DspAscII8x16(15,80,BLUE,vocabk.f);/#elseLcd_DspHz16(15,100,BLUE,vocabk.e);/#endif else Lcd_DspHz16(15,120,BLUE,"未找到相应的单词"); DelayMs(600); Lcd_DspHz16(15,120,WHITE,"未找到相应的单词"); break; case 14: wordwordIndex='0' wordIndex=0; for(i=0;i<20;i+) if(strcmp(word,vocabi.c)=0) j=0; k=i; break; else j=1; if(j=0) /#ifdef Eng_v Lcd_DspAscII8x16(15,40,BLUE,vocabk.c);Lcd_DspAscII8x16(15,60,BLUE,vocabk.d);Lcd_DspAscII8x16(15,80,BLUE,vocabk.f);/#elseLcd_DspHz16(15,100,BLUE,vocabk.e);/#endif else if(20>x>0) for(i = 0; i < 20; i+) vocabx.ci=wordi; wordi='0' Lcd_DspAscII8x16(15,40,BLUE,vocabx.c); x+; else x=15; /Lcd_DspAscII8x16(15,45,BLUE,word); for(i = 0; i < 20; i+) wordi='0' break; case 15: /Lcd_Draw_Box(10,40,310,80,GREEN); break; if(num!=0&&counter!=0) switch(3*(num-1)+counter-1) case 0: bbyte='a'break; case 1: bbyte='b'break; case 2: bbyte='c'break; case 3: bbyte='d'break; case 4: bbyte='e'break; case 5: bbyte='f'break; case 6: bbyte='g'break; case 7: bbyte='h'break; case 8: bbyte='i'break; case 9: bbyte='j'break; case 10: bbyte='k'break; case 11: bbyte='l'break; case 12: bbyte='m'break; case 13: bbyte='n'break; case 14: bbyte='o'break; case 15: bbyte='p'break; case 16: bbyte='q'break; case 17: bbyte='r'break; case 18: bbyte='s'break; case 19: bbyte='t'break; case 20: bbyte='u'break; case 21: bbyte='v'break; case 22: bbyte='w'break; case 23: bbyte='x'break; case 24: bbyte='y'break; case 25: bbyte='z'break; case 26: bbyte='y'break; num=0;counter=0; if(m=0) wordwordIndex=bbyte; wordIndex+; /n+=10; Lcd_DspAscII8x16(15,210,BLUE,word); / Uart_Printf("Key is:%x r",input_char); /* name:key_read* func:read key value* para:none* ret:key value, -1 - error* modify:* comment:*/inline int key_read()int value;char temp;/* read line 1 */temp = *(keyboard_base+0xfd);/* not 0xF mean key down */if( temp & KEY_VALUE_MASK) != KEY_VALUE_MASK)if( (temp&0x1) = 0 )value = 3;else if( (temp&0x2) = 0 )value = 2;else if( (temp&0x4) = 0 )value = 1;else if( (temp&0x8) = 0 )value = 0;while( temp & KEY_VALUE_MASK) != KEY_VALUE_MASK) / releasetemp = *(keyboard_base+0xfd);return value;/* read line 2 */temp = *(keyboard_base+0xfb);/* not 0xF mean key down */if( temp & KEY_VALUE_MASK) != KEY_VALUE_MASK)if( (temp&0x1) = 0 )value = 7;else if( (temp&0x2) = 0 )value = 6;else if( (temp&0x4) = 0 )value = 5;else if( (temp&0x8) = 0 )value = 4;while( temp & KEY_VALUE_MASK) != KEY_VALUE_MASK) / releasetemp = *(keyboard_base+0xfb);return value;/* read line 3 */temp = *(keyboard_base+0xf7);/* not 0xF mean key down */if( temp & KEY_VALUE_MASK) != KEY_VALUE_MASK)if( (temp&0x1) = 0 )value = 0xb;else if( (temp&0x2) = 0 )value = 0xa;else if( (temp&0x4) = 0 )value = 9;else if( (temp&0x8) = 0 )value = 8;while( temp & KEY_VALUE_MASK) != KEY_VALUE_MASK) / releasetemp = *(keyboard_base+0xf7);return value;/* read line 4 */temp = *(keyboard_base+0xef);/* not 0xF mean key down */if( temp & KEY_VALUE_MASK) != KEY_VALUE_MASK)if( (temp&0x1) = 0 )value = 0xf;else if( (temp&0x2) = 0 )value = 0xe;else if( (temp&0x4) = 0 )value = 0xd;else if( (temp&0x8) = 0 )value = 0xc;while( temp & KEY_VALUE_MASK) != KEY_VALUE_MASK) / releasetemp = *(keyboard_base+0xef);return value;return -1;/* name:Eint4567Isr* func:* para:none* ret:none* modify:* comment:*/void Eint4567Isr(void)unsigned char which_int;Uart_Printf("n SB2 or SB3 had pressed and light LED."); which_int=rEXTINTPND; rEXTINTPND=0xf;/clear EXTINTPND reg. rI_ISPC=BIT_EINT4567;/clear pending_bit if(which_int = 4)/ SB2 Led_Display(0x0); Led_Display(0x1); else if(which_int = 8)/ SB3 Led_Display(0x0); Led_Display(0x2); (2)LCD模块流程图:开始LCD初始化显示开机画面显示操作界面结束源代码:/* File:lcd.c* Author:embest* Desc:LCD control and display functions* History:*/*- include files -*/#include "lcd.h"/#include "bmp.h"#include "44b.h"/*- global variables -*/INT32U aLcdActiveBufferLCD_YSIZELCD_XSIZE/4;/*- extern variables -*/extern const INT8U aucTempBitmap76800;/*- function code -*/* name:Lcd_Init()* func:Initialize LCD Controller* para:none* ret:none* modify:* comment:*/void Lcd_Init (void) rDITHMODE=0x12210;rDP1_2 =0xa5a5; rDP4_7 =0xba5da65;rDP3_5 =0xa5a5f;rDP2_3 =0xd6b;rDP5_7 =0xeb7b5ed;rDP3_4 =0x7dbe;rDP4_5 =0x7ebdf;rDP6_7 =0x7fdfbfe; / disable,8B_SNGL_SCAN,WDLY=16clk,WLH=16clk,rLCDCON1=(0x0)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_COLOR<<12);/ LINEBLANK=10 (without any calculation) rLCDCON2=(LINEVAL)|(HOZVAL_COLOR<<10)|(10<<21); rLCDCON3=0;/ 256-color, LCDBANK, LCDBASEUrLCDSADDR1= (0x3<<27) | ( (unsigned int)aLcdActiveBuffer>>22)<<21 ) | M5D(unsigned int)aLcdActiveBuffer>>1);rLCDSADDR2= M5D(unsigned int)aLcdActiveBuffer+(SCR_XSIZE*LCD_YSIZE)>>1) | (MVAL<<21);rLCDSADDR3= (LCD_XSIZE/2) | ( (SCR_XSIZE-LCD_XSIZE)/2)<<9 );/The following value has to be changed for better display.rREDLUT =0xfdb96420; / 1111 1101 1011 1001 0110 0100 0010 0000rGREENLUT=0xfdb96420; / 1111 1101 1011 1001 0110 0100 0010 0000rBLUELUT =0xfb40; / 1111 1011 0100 0000rLCDCON1=(0x1)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_COLOR<<12);/rPDATE=rPDATE&0x0e;rPDATE=0xfe;Lcd_Clr();/* name:Lcd_Clr()* func:clear LCD screen* para:none * ret:none* modify:* comment:*/void Lcd_Clr(void)INT32U i;INT32U *pDisp = (INT32U*)aLcdActiveBuffer;for (i = 0; i < (SCR_XSIZE * SCR_YSIZE / 4); i+)*pDisp+ = ALLWHITE;/* name:LcdClrRect()* func:fill appointed area with appointed color* para:usLeft,usTop,usRight,usBottom - area's rectangle acme coordinate*ucColor - appointed color value* ret:none* modify:* comment:also as clear screen function */void LcdClrRect(INT16 usLeft, INT16 usTop, INT16 usRight, INT16 usBottom, INT8U ucColor)INT32U i, j;INT8U *pDisp = (INT8U*)aLcdActiveBuffer;for(i=usTop;i<=usBottom;i+)for(j=usLeft;j<=usRight;j+)LCD_PutPixel(j, i, ucColor);#ifdef MON_LCD/* name:LcdClrRect()* func:fill appointed area with appointed color* para:usLeft,usTop,usRight,usBottom - area's rectangle acme coordinate*ucColor - appointed color value* ret:none* modify:* comment:also as clear screen function */void LcdClrRect(INT16 usLeft, INT16 usTop, INT16 usRight, INT16 usBottom, INT8U ucColor)INT16 i=0;INT16 k,l;INT16 m;INT32U ulColor = (ucColor << 28) | (ucColor << 24) | (ucColor << 20) | (ucColor << 16) | (ucColor << 12) | (ucColor << 8) | (ucColor << 4) | ucColor;if(usRight-usLeft)<=8)for(i=usTop;i<=usBottom;i+)f

    注意事项

    本文(嵌入式课程设计电子词典硬件设计.doc)为本站会员(赵**)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

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

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开