《嵌入式软件程序设计实验报告(共9页).doc》由会员分享,可在线阅读,更多相关《嵌入式软件程序设计实验报告(共9页).doc(9页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、精选优质文档-倾情为你奉上嵌入式软件程序设计实验报告实验题目: 彩色屏幕测试实验班 级: 学 号: 姓 名: 一、实验项目:彩色屏幕测试实验二、实验时间: 2011年11月20号三、实验地点: 2号教学区106机房四、实验目的:1、了解彩色LCD显示屏的工作原理和接口 2、掌握arm与LCD显示屏的接口原理 3、掌握LCD显示字符,色彩及绘制简单图形的编程五、实验要求:1、实验前认真预习实验指导书,按要求在纸上编写好程序。 2、不要用手直接摸触实验设备印刷板上的线路引线和集成块的引脚,特别是冬天,以防人体所带静电损坏芯片。六、实验仪器:嵌入式教学实验系统,嵌入式操作软件平台,计算机,直流稳压电
2、源,仿真器,接口模块,示波器七、 实验编程代码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)|(25)|(MVAL_USED7)|(0x38)|(0x310)|(CLK
3、VAL_COLOR12);/ LINEBLANK=10 (without any calculation) rLCDCON2 = (LINEVAL)|(HOZVAL_COLOR10)|(1021); rLCDCON3 = 0;/ 256-color, LCDBANK, LCDBASEUrLCDSADDR1 = (0x322)1);rLCDSADDR2 = M5D(unsigned int)g_unLcdActiveBuffer+(SCR_XSIZE*LCD_YSIZE)1) | (MVAL21);rLCDSADDR3 = (LCD_XSIZE/2) | ( (SCR_XSIZE-LCD_XSI
4、ZE)/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)|(25)|(MVAL_USED7)|(0x38)|(0x310)|(CLKVAL_COLOR12);rPD
5、ATE=rPDATE&0x0e;lcd_clr();void lcd_clr(void)UINT32T i;UINT32T *pDisp = (UINT32T*)g_unLcdActiveBuffer;for (i = 0; i (SCR_XSIZE * SCR_YSIZE / 4); i+)*pDisp+ = ALLWHITE;#ifdef LCD_STN256_COLORvoid lcd_clr_rect(UINT16T usLeft, UINT16T usTop, UINT16T usRight, UINT16T usBottom, UINT8T ucColor)UINT32T i, j
6、;UINT8T *pDisp = (UINT8T*)g_unLcdActiveBuffer;for(i=usTop;i=usBottom;i+)for(j=usLeft;j=usRight;j+)LCD_PutPixel(j, i, ucColor);#endif#ifdef LCD_STN256_GRAYvoid lcd_clr_rect(UINT16T usLeft, UINT16T usTop, UINT16T usRight, UINT16T usBottom, UINT8T ucColor)UINT16T i=0;UINT16T k,l;UINT16T m;UINT32T ulCol
7、or = (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+)for(m=usLeft;m=usRight;m+)LCD_PutPixel(m, i, ucColor);return;if(usLeft%8)=0)k=usLeft;elsek=(usLeft/8)*8+8;if( usRight%8)=0)l= usRight;els
8、el=( usRight/8)*8;for(i=usTop;i=usBottom;i+)for(m=usLeft;m=(k-1);m+)LCD_PutPixel(m, i, ucColor);for(m=k;ml;m+=8)(*(UINT32T*)(g_unLcdActiveBuffer + i * SCR_XSIZE / 2 + m / 2) = ulColor;for(m=l;m= usDy & (usX0 usX1) | (usDy usDx) & (usY0 usY1) ) GUISWAP(usX1, usX0); GUISWAP(usY1, usY0); y_sign = (usY1
9、 - usY0) / usDy; x_sign = (usX1 - usX0) / usDx; if( usDx = usDy ) for( wCurx = usX0, wCury = usY0, wNextx = usX1, wNexty = usY1, decision = (usDx 1); wCurx = usDx ) decision -= usDx; wCury += y_sign; wNexty -= y_sign; for( wpy = wCury - usWidth / 2; wpy = wCury + usWidth / 2; wpy+ ) LCD_PutPixel(wCu
10、rx, wpy, ucColor); for( wpy = wNexty - usWidth / 2; wpy 1); wCury = usDy ) decision -= usDy; wCurx += x_sign; wNextx -= x_sign; for( wpx = wCurx - usWidth / 2; wpx = wCurx + usWidth / 2; wpx+ ) LCD_PutPixel(wpx, wCury, ucColor); for( wpx = wNextx - usWidth / 2; wpx = wNextx + usWidth / 2; wpx+ ) LCD
11、_PutPixel(wpx, wNexty, ucColor); /* name:lcd_draw_hline()* func:Draw horizontal line with appointed color* para:usX0,usY0 - lines start point coordinate*usX1 - lines end point X-coordinate*ucColor - appointed color value*usWidth - lines width* ret:none* modify:* comment:*/void lcd_draw_hline(UINT16T
12、 usX0, UINT16T usX1, UINT16T usY0, UINT8T ucColor, UINT16T usWidth)UINT16T usLen; if( usX1 0 ) usLen = usX1 - usX0 + 1; while( (usLen-) 0 ) LCD_PutPixel(usX0 + usLen, usY0, ucColor); usY0+; /* name:lcd_draw_vline()* func:Draw vertical line with appointed color* para:usX0,usY0 - lines start point coo
13、rdinate*usY1 - lines end point Y-coordinate*ucColor - appointed color value*usWidth - lines width* ret:none* modify:* comment:*/void lcd_draw_vline (UINT16T usY0, UINT16T usY1, UINT16T usX0, UINT8T ucColor, UINT16T usWidth)UINT16T usLen; if( usY1 0 ) usLen = usY1 - usY0 + 1; while( (usLen-) 0 ) LCD_PutPixel(usX0, usY0 + usLen, ucColor); usX0+; 八、 实验结果展示专心-专注-专业