嵌入式LED燈顯示_第1頁
嵌入式LED燈顯示_第2頁
嵌入式LED燈顯示_第3頁
嵌入式LED燈顯示_第4頁
嵌入式LED燈顯示_第5頁
已閱讀5頁,還剩21頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、【設計題目】矩陣LED字符顯示控制系統設計【設計目的】1掌握無操作系統下的硬件軟件設計原理和方法;2進一步熟悉ARM 處理器的基本結構、指令集、存儲系統以及基本接口編程;3熟悉嵌入式系統各部件的硬件初始化過程以及基本IO控制方法。4掌握矩陣LED 的應用原理【設計內容】1利用sys_init初始化程序,利用串口實現PC和開發板的數據通信;2編寫S3C2410X 處理器的點陣屏驅動程序;3編寫S3C2410X 處理器的點陣屏應用程序。4. 當程序運行等待要求從串口輸入學生姓名的字符串在矩陣LED上顯示出來。【實驗環境】硬件:Embest EduKit-IV 平臺,ULINK2 仿真器套件,PC

2、機;軟件:Vision IDE for ARM 集成開發環境,Windows XP。【相關知識綜述】背景知識、原理算法等一、硬件部分1點陣屏的結構電路圖1點陣屏的結構電路圖上QL1-QL16為行驅動信號,每個信號控制一行, LR1LR16 是點陣屏的列驅動信號,每一個信號控制一列。當行信號為高電平而列信號為低電平,對應的LED就會亮。CD40941#芯片LL1LL8LL7RSTRDATACLKSTROBECD40942#芯片LL9LL16LL15DATACLKGPB5LQSGPC0GPD10GPB4GPG8STROBELOELOELSTR列鎖存信號2,S3C2410與點陣屏的連接CD40941

3、#芯片LL1LL8LL7RSTRDATACLKSTROBECD40942#芯片LL9LL16LL15DATACLKGPB5LQSGPC0GPD10GPB4GPG8STROBELOELOELSTR列鎖存信號圖2 S3C2410ARM處理器與兩片CD4094連接得到16位行選信號圖以上電路可以通過S3C2410GPIO口把CPU的并行數據(16位兩個字節的數據)打入到兩個CD4094芯片中并鎖存起來變成LL1-LL16的行選信號。各信號的作用如下表1; 2410引腳CD4094信號電平高低各信號的作用GPB4STORBE(RSTR)高行鎖存允許,將串行數據大入到CD4094相應位低不鎖存GPB5L

4、OE高CD4094 上鎖存的并行數據全部輸出(輸出使能)低CD4094 上鎖存的并行數據不輸出GPD10CLK高CD4094 允許串行輸入的數據發生變化低CD4094 不允許串行輸入的數據發生變化GPC0DATA高表明串行數據為1低表明串行數據為0GPG8STORBELSTR高列鎖存允許,將串行數據大入到CD4094相應位低不鎖存3點陣屏的保護電路圖3 點陣屏的保護電路圖為了保護LED屏加了對應的電阻實現行限流作用,即LL1-LL16變為RQ1-RQ164LED的驅動 加入行驅動電路的目的是實現LED燈的驅動。這樣由RQ1-RQ16變為行驅動信號QL1-QL16。Q11-QL16為圖1中的行驅

5、動信號。圖4 行驅動電路【設計思路】采用的數據結構、主要的函數說明、程序流程設計圖等主要的函數說明:led_init(); :LED顯示矩陣初始化static void refresh_l_display_array(u8 bits, u8 *str) :顯示字符void led_logo_disp(void) :顯示logostruct fonts_struct unsigned char ascii_width;unsigned char ascii_height;unsigned char * ascii_code;unsigned char ascii_beg;unsigned cha

6、r ascii_end;【源程序清單】/* File:main.c* Author:embest* Desc:c main entry* History:*/*-*/* include files */*-*/#include "2410lib.h"#include "sys_init.h"#include "fonts.h"#include "led16x16.h"/* name:main* func:c code entry* para:none* ret:none* modify:* comment:*/in

7、t main(void) char c; sys_init();/ Initial systemwhile(1)uart_printf("n Please Look At The 16X16 LEDS And Choose Keyn");uart_printf("1、向左移動n");uart_printf("2、向左閃爍移動n");uart_printf("3、向右移動n");uart_printf("4、向右閃爍移動n"); c=uart_getch(); uart_printf("

8、%c",c); led_init(); / Initial led diplay if(c='1') l_char_out(0,"_學號"); left_out(0,"abcdef"); else if(c='2') l_flash_char_out(0,"_學號"); left_out_flash(0,"abcdef"); else if(c='3') r_char_out(0,"_學號");right_out(0,"abcd

9、ef"); else if(c='4') r_flash_char_out(0,"_學號"); right_out_flash(0,"abcdef"); /* File:Dotled.c* Author:embest* Desc:DotLed_Test * History:*/*-*/* include files */*-*/#include <stdio.h>#include "2410lib.h"#include "fonts.h"#include "led16

10、x16.h"/*-*/* function declare */*-*/extern void led_char_disp(void);/*-*/* global variables */*-*/u8 l_display_array2*16;u8 assic_buffer3*16;/*=l_display_array:+-+-+| | | | D | E | | | | +-+-+A buffer data and B buffer data ->D buffer dataB buffer data and C buffer data ->E buffer dataass

11、ic_buffer:+-+-+-+| | | | A | B | C |<- update the C buffer and move the B buffer data to the A buffer| | | | and move the C buffer data to the B buffer data+-+-+-+=*/* name:led_update* func:refresh the led display* para:none* ret:none* modify:* comment:*/static void led_update(void)int j = 20;whi

12、le(j-)led_char_disp();/* name:l_display_scroll* func:shift the display* para:bits:the position str:point the buffer* ret:none* modify:* comment:*/static void refresh_l_display_array(u8 bits, u8 *str)u32 i;u32 remaining_bits = 8-bits; for(i=0;i<16;i+)l_display_array2*i = (*str<<bits) |(*(str

13、+16)>>remaining_bits);l_display_array2*(i+1)-1 = (*(str+16)<<bits) |(*(str+32)>>remaining_bits);str+; static void refresh_flash_display_array(u8 bits, u8 *str)u32 i;for(i=0;i<16;i+)l_display_array2*i = 0;l_display_array2*(i+1)-1 =0;str+;/* name:l_display_scroll* func:scroll the

14、display* para:str:point the buffer* ret:none* modify:* comment:*/static void l_display_scroll ( u8 *str )int i;for(i=0;i<8;i+)refresh_l_display_array(i, str);led_update(); static void l_flash_display_scroll ( u8 *str )int i;for(i=0;i<8;i+)refresh_l_display_array(i, str);led_update();refresh_fl

15、ash_display_array(i, str);led_update();static void r_display_scroll ( u8 *str )int i;for(i=8;i>0;i-)refresh_l_display_array(i, str);led_update(); static void r_flash_display_scroll ( u8 *str )int i;for(i=8;i>0;i-)refresh_l_display_array(i, str);led_update();refresh_flash_display_array(i, str);

16、led_update();/* name:copy_data* func:copy data* para:dst:point the dest data src:points the source data* ret:none* modify:* comment:*/static void copy_data(u8 *dst, u8 *src, u32 size)while(size-)*(dst+) = *(src+);/* name:refresh_assic_buffer* func:refresh buffer* para:str:points the new char* ret:no

17、ne* modify:* comment:*/static void l_refresh_assic_buffer(u8 *str)copy_data(&assic_buffer0, &assic_buffer16,16);copy_data(&assic_buffer16, &assic_buffer32,16);copy_data(&assic_buffer32, str,16);l_display_scroll(assic_buffer);static void l_flash_refresh_assic_buffer(u8 *str)copy_d

18、ata(&assic_buffer0, &assic_buffer16,16);copy_data(&assic_buffer16, &assic_buffer32,16);copy_data(&assic_buffer32, str,16);l_flash_display_scroll(assic_buffer);static void r_refresh_assic_buffer(u8 *str)copy_data(&assic_buffer32, &assic_buffer16,16);copy_data(&assic_bu

19、ffer16, &assic_buffer0,16);copy_data(&assic_buffer0, str,16);r_display_scroll(assic_buffer);static void r_flash_refresh_assic_buffer(u8 *str)copy_data(&assic_buffer32, &assic_buffer16,16);copy_data(&assic_buffer16, &assic_buffer0,16);copy_data(&assic_buffer0, str,16);r_fl

20、ash_display_scroll(assic_buffer);/* name:char_out* func:display the chars* para:font:0 str:points of the chars* ret:none* modify:* comment:*/ void l_char_out(u8 font, u8 *str)u8 *str_ptr;u8 glyph;glyph = ( u8 )*str;while(glyph != '0' )str_ptr = fontsfont.ascii_code + ( glyph - fontsfont.asci

21、i_beg) * fontsfont.ascii_height;l_refresh_assic_buffer(str_ptr);str+;glyph = ( u8 )*str;void l_flash_char_out(u8 font, u8 *str)u8 *str_ptr;u8 glyph;glyph = ( u8 )*str;while(glyph != '0' )str_ptr = fontsfont.ascii_code + ( glyph - fontsfont.ascii_beg) * fontsfont.ascii_height;l_flash_refresh_

22、assic_buffer(str_ptr);str+;glyph = ( u8 )*str;void r_char_out(u8 font, u8 *str)u8 *str_ptr;u8 glyph;glyph = ( u8 )*str;while(glyph != '0' )str_ptr = fontsfont.ascii_code + ( glyph - fontsfont.ascii_beg) * fontsfont.ascii_height;r_refresh_assic_buffer(str_ptr);str+;glyph = ( u8 )*str;void r_f

23、lash_char_out(u8 font, u8 *str)u8 *str_ptr;u8 glyph;glyph = ( u8 )*str;while(glyph != '0' )str_ptr = fontsfont.ascii_code + ( glyph - fontsfont.ascii_beg) * fontsfont.ascii_height;r_flash_refresh_assic_buffer(str_ptr);str+;glyph = ( u8 )*str;void left_out(u8 font, u8 *str)u8 *str_ptr;u8 glyp

24、h;glyph = ( u8 )*str;while(glyph != '0' )str_ptr = leftcodefont.ascii_code + ( glyph - leftcodefont.ascii_beg) * leftcodefont.ascii_height;l_refresh_assic_buffer(str_ptr);str+;glyph = ( u8 )*str; void left_out_flash(u8 font, u8 *str)u8 *str_ptr;u8 glyph;glyph = ( u8 )*str;while(glyph != '

25、;0' )str_ptr = leftcodefont.ascii_code + ( glyph - leftcodefont.ascii_beg) * leftcodefont.ascii_height;l_flash_refresh_assic_buffer(str_ptr);str+;glyph = ( u8 )*str;void right_out(u8 font, u8 *str)u8 *str_ptr;u8 glyph;glyph = ( u8 )*str;while(glyph != '0' )str_ptr = rightcodefont.ascii_c

26、ode + ( glyph - rightcodefont.ascii_beg) * rightcodefont.ascii_height;r_refresh_assic_buffer(str_ptr);str+;glyph = ( u8 )*str; void right_out_flash(u8 font, u8 *str)u8 *str_ptr;u8 glyph;glyph = ( u8 )*str;while(glyph != '0' )str_ptr = rightcodefont.ascii_code + ( glyph - rightcodefont.ascii_

27、beg) * rightcodefont.ascii_height;r_flash_refresh_assic_buffer(str_ptr);str+;glyph = ( u8 )*str;/* name:led_init* func:initial the led display* para:none* ret:none* modify:* comment:*/void led_init(void)rGPBCON = rGPBCON & 0xfff0ff | 0x500; / GPB4,GPB5=01:OutputrGPCCON = rGPCCON & 0xffff3ffc

28、 | 0x4001; / GPC0,GPC7=01:OutputrGPDCON = rGPDCON & 0xffcfffff | 0x100000; / GPD10=01:OutputrGPGCON = rGPGCON & 0xfffcffff | 0x10000; / GPG8=01:Output/* File:fonts.c* Author:embest* Desc:DotLed_Test * History:*/*-*/* include files */*-*/#include "fonts.h"/ - ASCII字模的數據表 - /unsigned

29、 char nAsciiDot = / ASCII0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, / - -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x3C,0x3C,0x3C,0x18,0x18, / -!-0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x24,0x00,0x00,0x00, / -"-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x

30、00,0x6C,0x6C,0xFE,0x6C,0x6C, / -#-0x6C,0xFE,0x6C,0x6C,0x00,0x00,0x00,0x00,0x18,0x18,0x7C,0xC6,0xC2,0xC0,0x7C,0x06, / -$-0x86,0xC6,0x7C,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC2,0xC6,0x0C,0x18, / -%-0x30,0x60,0xC6,0x86,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x6C,0x6C,0x38,0x76,0xDC, / -&-0xCC

31、,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x60,0x00,0x00,0x00, / -'-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x18,0x30,0x30,0x30,0x30, / -(-0x30,0x30,0x18,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x18,0x0C,0x0C,0x0C,0x0C, / -)-0x0C,0x0C,0x18,0x30,0x00,0x00,0x00,0x00,0x

32、00,0x00,0x00,0x00,0x00,0x66,0x3C,0xFF, / -*-0x3C,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x7E, / -+-0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, / -,-0x00,0x18,0x18,0x18,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE, / -

33、0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, / -.-0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x06,0x0C,0x18, / -/-0x30,0x60,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xC6,0xCE,0xD6,0xD6, / -0-0xE6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,0x

34、00,0x00,0x18,0x38,0x78,0x18,0x18,0x18, / -1-0x18,0x18,0x18,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0x06,0x0C,0x18,0x30, / -2-0x60,0xC0,0xC6,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0x06,0x06,0x3C,0x06, / -3-0x06,0x06,0xC6,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x1C,0x3C,0x6C,0xCC,0xFE, / -

35、4-0x0C,0x0C,0x0C,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0xC0,0xC0,0xC0,0xFC,0x0E, / -5-0x06,0x06,0xC6,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x60,0xC0,0xC0,0xFC,0xC6, / -6-0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0xC6,0x06,0x06,0x0C,0x18, / -7-0x30,0x30,0x30,0x30,0x00,0x00,0x00,0x00,

36、0x00,0x00,0x7C,0xC6,0xC6,0xC6,0x7C,0xC6, / -8-0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0x7E,0x06, / -9-0x06,0x06,0x0C,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00, / -:-0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00, /

37、 -;-0x00,0x18,0x18,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x0C,0x18,0x30,0x60, / -<-0x30,0x18,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00, / -=-0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x30,0x18,0x0C,0x06, / ->-0x0C,0x18,0x30,0x60,0x00,0x00,0x

38、00,0x00,0x00,0x00,0x7C,0xC6,0xC6,0x0C,0x18,0x18, / -?-0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xC6,0xDE,0xDE, / -0xDE,0xDC,0xC0,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x38,0x6C,0xC6,0xC6,0xFE, / -A-0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x66,0x66,0x66,0x7C,0

39、x66, / -B-0x66,0x66,0x66,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0xC2,0xC0,0xC0,0xC0, / -C-0xC0,0xC2,0x66,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x6C,0x66,0x66,0x66,0x66, / -D-0x66,0x66,0x6C,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x66,0x62,0x68,0x78,0x68, / -E-0x60,0x62,0x66,0xFE,0x00,0x00,0x

40、00,0x00,0x00,0x00,0xFE,0x66,0x62,0x68,0x78,0x68, / -F-0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0xC2,0xC0,0xC0,0xDE, / -G-0xC6,0xC6,0x66,0x3A,0x00,0x00,0x00,0x00,0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xFE,0xC6, / -H-0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x18,0x18,0x18,0x18

41、,0x18, / -I-0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x0C,0x0C,0x0C,0x0C,0x0C, / -J-0xCC,0xCC,0xCC,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0xE6,0x66,0x6C,0x6C,0x78,0x78, / -K-0x6C,0x66,0x66,0xE6,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x60,0x60,0x60,0x60,0x60, / -L-0x60,0x62,0x66,0xFE,0x00,0x00,

42、0x00,0x00,0x00,0x00,0xC6,0xEE,0xFE,0xFE,0xD6,0xC6, / -M-0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00,0x00,0x00,0xC6,0xE6,0xF6,0xFE,0xDE,0xCE, / -N-0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x6C,0xC6,0xC6,0xC6,0xC6, / -O-0xC6,0xC6,0x6C,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x66,0x66,0x66,0x

43、7C,0x60, / -P-0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6, / -Q-0xC6,0xD6,0xDE,0x7C,0x0C,0x0E,0x00,0x00,0x00,0x00,0xFC,0x66,0x66,0x66,0x7C,0x6C, / -R-0x66,0x66,0x66,0xE6,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xC6,0x60,0x38,0x0C, / -S-0x06,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x7E,0x5A,0x18,

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論