1、嵌入式LED灯显示【设计题目】矩阵LED字符显示控制系统设计【设计目的】1掌握无操作系统下的硬件软件设计原理和方法;2进一步熟悉ARM 处理器的基本结构、指令集、存储系统以及基本接口编程;3熟悉嵌入式系统各部件的硬件初始化过程以及基本IO控制方法。4掌握矩阵LED 的应用原理【设计内容】1利用sys_init初始化程序,利用串口实现PC和开发板的数据通信;2编写S3C2410X 处理器的点阵屏驱动程序;3编写S3C2410X 处理器的点阵屏应用程序。4. 当程序运行等待要求从串口输入学生姓名的字符串在矩阵LED上显示出来。 【实验环境】硬件:Embest EduKit-IV 平台,ULINK2
2、 仿真器套件,PC 机;软件:Vision IDE for ARM 集成开发环境,Windows XP。【相关知识综述】背景知识、原理算法等 一、硬件部分1点阵屏的结构电路图1点阵屏的结构电路图上QL1-QL16为行驱动信号,每个信号控制一行, LR1LR16 是点阵屏的列驱动信号,每一个信号控制一列。当行信号为高电平而列信号为低电平,对应的LED就会亮。2,S3C2410与点阵屏的连接图2 S3C2410ARM处理器与两片CD4094连接得到16位行选信号图以上电路可以通过S3C2410GPIO口把CPU的并行数据(16位两个字节的数据)打入到两个CD4094芯片中并锁存起来变成LL1-LL
3、16的行选信号。各信号的作用如下表1; 2410引脚CD4094信号电平高低各信号的作用GPB4STORBE(RSTR)高行锁存允许,将串行数据大入到CD4094相应位低不锁存GPB5LOE高CD4094 上锁存的并行数据全部输出(输出使能)低CD4094 上锁存的并行数据不输出GPD10CLK高CD4094 允许串行输入的数据发生变化低CD4094 不允许串行输入的数据发生变化GPC0DATA高表明串行数据为1低表明串行数据为0GPG8STORBELSTR高列锁存允许,将串行数据大入到CD4094相应位低不锁存3点阵屏的保护电路图3 点阵屏的保护电路图为了保护LED屏加了对应的电阻实现行限流
4、作用,即LL1-LL16变为RQ1-RQ164LED的驱动 加入行驱动电路的目的是实现LED灯的驱动。这样由RQ1-RQ16变为行驱动信号QL1-QL16。Q11-QL16为图1中的行驱动信号。图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_wid
5、th; unsigned char ascii_height; unsigned char * ascii_code; unsigned char ascii_beg; unsigned char 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
6、 code entry* para: none* ret: none* modify:* comment: */int main(void) char c; sys_init(); / Initial system while(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(%
7、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,abcdef); else if(c=4) r_flash_char_out(0,_学号); right_out_flash(0,abcdef); /* File: Dotled.c* Author: embes
8、t* Desc: DotLed_Test * History: */*-*/* include files */*-*/#include #include 2410lib.h#include fonts.h#include led16x16.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 | | |
9、 | +-+-+A buffer data and B buffer data -D buffer dataB buffer data and C buffer data -E buffer dataassic_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: refres
10、h the led display* para: none* ret: none* modify:* comment: */static void led_update(void) int j = 20; while(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 bi
11、ts, u8 *str) u32 i; u32 remaining_bits = 8-bits; for(i=0;i16;i+) l_display_array2*i = (*strremaining_bits); l_display_array2*(i+1)-1 = (*(str+16)remaining_bits); str+; static void refresh_flash_display_array(u8 bits, u8 *str) u32 i; for(i=0;i16;i+) l_display_array2*i = 0; l_display_array2*(i+1)-1 =0
12、; str+; /* name: l_display_scroll* func: scroll the display* para: str:point the buffer* ret: none* modify:* comment: */static void l_display_scroll ( u8 *str ) int i; for(i=0;i8;i+) refresh_l_display_array(i, str); led_update(); static void l_flash_display_scroll ( u8 *str ) int i; for(i=0;i0;i-) r
13、efresh_l_display_array(i, str); led_update(); static void r_flash_display_scroll ( u8 *str ) int i; for(i=8;i0;i-) refresh_l_display_array(i, str); led_update(); refresh_flash_display_array(i, str); led_update(); /* name: copy_data* func: copy data* para: dst:point the dest data src:points the sourc
14、e 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: none* modify:* comment: */static void l_refresh_assic_buffer(u8 *str) copy_data(&assic_buf
15、fer0, &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_data(&assic_buffer0, &assic_buffer16,16); copy_data(&assic_buffer16, &assic_buffer32,16); copy_data(&as
16、sic_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_buffer16, &assic_buffer0,16); copy_data(&assic_buffer0, str,16); r_display_scroll(assic_buffer);static void r_flash_refresh_assic_b
17、uffer(u8 *str) copy_data(&assic_buffer32, &assic_buffer16,16); copy_data(&assic_buffer16, &assic_buffer0,16); copy_data(&assic_buffer0, str,16); r_flash_display_scroll(assic_buffer);/* name: char_out* func: display the chars* para: font:0 str:points of the chars* ret: none* modify:* comment: */ void
18、 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.ascii_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 gly
19、ph; glyph = ( u8 )*str; while(glyph != 0 ) str_ptr = fontsfont.ascii_code + ( glyph - fontsfont.ascii_beg) * fontsfont.ascii_height; l_flash_refresh_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_flash_char_out(u8 font, u8 *str) u8 *str_ptr; u8 glyph; glyph
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1