基于单片机和CPLD的LED点阵显示系统附件.doc_第1页
基于单片机和CPLD的LED点阵显示系统附件.doc_第2页
基于单片机和CPLD的LED点阵显示系统附件.doc_第3页
基于单片机和CPLD的LED点阵显示系统附件.doc_第4页
基于单片机和CPLD的LED点阵显示系统附件.doc_第5页
已阅读5页,还剩8页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

附 录/* 51控制的点阵显示C程序 */#include reg51.H#include stdio.h#define uint unsigned int#define uchar unsigned charsbit G1 = P10;sbit G2 = P11;sbit R1 = P12;sbit R2 = P13;sbit RK_595 = P14;sbit SK_595 = P15;sbit A_138 = P20;sbit B_138 = P21;sbit C_138 = P22;sbit D_138 = P23;sbit EN_138 = P24;void init_IO(void);void delay(uint T);void send_byte(uchar ldata);void disp(uchar code *ziku,uchar s_color);void disp_red(void);void disp_green(void);void disp_orange(void);uchar buf32=0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00;/定义32字节的缓冲区uchar code anquan1=0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /YY00x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0xc0,0x00,0x60,0x00,0x00,0x00,0x80,0x01,0xe0,0x01,0x60,0x00,0x00,0x00, 0xfe,0x3f,0x30,0x03,0x63,0x8c,0xff,0x07, /YY10xfe,0x3f,0x18,0x06,0x63,0x8c,0xff,0x07,0x06,0x30,0xc0,0x0c,0x63,0x8c,0x01,0x06,0x66,0x30,0xff,0x3f,0xff,0x8f,0x01,0x06, 0x60,0x00,0xfb,0x37,0xff,0x8f,0x01,0x06, /YY20xf7,0x3f,0xc0,0x00,0x60,0x80,0x01,0x06,0xf7,0x3f,0xc0,0x00,0x60,0x80,0x01,0x06,0x30,0x06,0xfc,0x0f,0x63,0x8c,0x01,0x06, 0x70,0x06,0xfc,0x0f,0x63,0x8c,0x01,0x06, /YY30xc0,0x03,0xc0,0x00,0x63,0x8c,0xff,0x07,0xe0,0x0f,0xc3,0x00,0xff,0x8f,0xff,0x07,0x7e,0x3c,0xfe,0x1f,0xff,0x8f,0x01,0x06,0x1c,0x30,0xfe,0x1f,0x00,0x0c,0x00,0x00, /YY40x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x9f,0x83,0x73,0xfe,0x03,0x00, 0x00,0xe0,0x1f,0xc7,0x71,0xfe,0x03,0x00, /YY50x00,0xe0,0x00,0xee,0x70,0x70,0x00,0x00,0x00,0xe0,0x1f,0x7c,0x70,0x70,0x00,0x00,0x00,0xe0,0x1f,0x38,0x70,0x70,0x00,0x00, 0x00,0xe0,0x00,0x7c,0x70,0x70,0x00,0x00, /YY60x00,0xe0,0x00,0xee,0x70,0x70,0x00,0x00,0x00,0xe0,0x1f,0xc7,0x71,0x70,0x00,0x00,0x00,0xe0,0x9f,0x83,0x73,0x70,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /YY70x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00; void init_IO(void) P0=0xff; P1=0xff; P2=0xff; P3=0xff; /SP=0X60; void delay(uint T)uint t=T;for(;t0;t-);void disp(uchar code *ziku,uchar s_color) uchar d_color; uchar i,j,ldata1,ldata2,hscan; uchar code *temp; /*temp=&anquan10;*/ temp=ziku; d_color=s_color; for(hscan=0;hscan16;hscan+) EN_138 = 0;for(i=8*hscan;i8*(hscan+1);i+) ldata1=*(temp+i); /取上半屏字模数据(一个字节) ldata2=*(temp+128+i);/取下半屏字模数据 for (j=0;j=1; ldata2=1; SK_595 = 1; /* 一行8个字节数据发完后向595发出锁存数据脉冲信号*/ RK_595 = 0; RK_595 = 1; P2 = hscan;/行扫描信号由P2口P2.0,P2.1,P2.2送出,再经138译码器译码输出 EN_138= 1; /使能138译码器,开始输出行扫描信号 delay(20); void disp_red(void) uchar s_color; uchar code *ziku; ziku=anquan1; s_color=1; disp(ziku,s_color); void disp_green(void) uchar code *ziku; uchar s_color; ziku=anquan1; s_color = 2; disp(ziku,s_color); void disp_orange(void) uchar code *ziku; uchar s_color; ziku=anquan1; s_color = 3; disp(ziku,s_color); void disp_left(uchar code *ziku,uchar s_color,uchar speed) uchar d_color; uchar s;/left shift speed uchar i,j,k,ldata1,ldata2,hscan; uchar code *temp; /*temp=&anquan10;*/ temp=ziku; d_color=s_color; s=speed; /EN_138=0; for(i=0;i8;i+) for(j=0;j32;j+) bufj=*(temp+i+j*8); for(k=0;k8;k+) delay(s); ldata1=*(temp+i); /取上半屏字模数据(一个字节) ldata2=*(temp+128+i);/取下半屏字模数据 for (hscan=0;hscan=1; bufhscan+16=1; /* 一行8个字节数据发完后向595发出锁存数据脉冲信号*/ / RK_595 = 0; / RK_595 = 1; / P2 = hscan;/行扫描信号由P2口P2.0,P2.1,P2.2送出,再经138译码器译码输出 / EN_138= 1; /使能138译码器,开始输出行扫描信号 delay(20); void disp_shift(void) uchar code *ziku; uchar s_color; uchar speed; ziku=anquan1; s_color = 3; speed=1000; disp_left(ziku,s_color,speed); void main( )uchar i,j,k;init_IO();while(1) for(i=0;i100;i+) disp_red(); for(j=0;j100;j+) disp_green(); for(k=0;k100;k+) disp_orange(); for(k=0;k100;k+) disp_shift(); VHDL地址形成模块程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity scan isport(add:out std_logic_vector(9 downto 0); clr,clk,en:in std_logic; q:buffer std_logic_vector(12 downto 0); ld:out std_logic; hdc:out std_logic);end scan;architecture a of scan isbeginadd0=q(3)add1=q(4)add2=q(5)add3=q(6)add4=q(7)add5=q(8)add6=q(9)add7=q(10)add8=q(11)add9=q(12)hdc=q(1)andq(2)and q(3)andq(4)and q(5)andq(6)and q(7)andq(8);process(clk,clr)beginif (clr=1) then q=0000000000000; else if(clkevent and clk=1)thenif(en=1)thenqq+1;if(q(0)=0and q(1)=0and q(2)=0)thenld=0elseld=1;end if; end if;end if;end process;end a;串/并进-串出移位寄存器程序library ieee;use ieee.std_logic_1164.all;entity sreg597 isport(srclrn:in std_logic; srldn:in std_logic; rclk:in std_logic; d:in std_logic_vector(7 downtown 0); srclk:out std_logic ser:in std_logic; qhn:out std_logic);end sreg597;architecture a of sreg597 issignal temperature8:std_logic_vector(7 downto 0);beginprocess(srclk, rclk,srclrn,srldn)beginif (srclrn=0) then tempeg8=00000000; qhn=tempreg8(7) else if(clkevent and clk=1)thenif(srldn=0and rclk=0)thentempreg8(0)=d(0);tempreg8(1)=d(1);tempreg8(2)=d(2);tempreg8(3)=d(3);tempreg8(4)=d(4);tempreg8(5)=d(5);tempreg8(6)=d(6);tempreg8(7)=d(7);qhn= tempreg8(7);elsetempreg8(0)=ser;tempreg8(1)=d(0);tempreg8(2)=d(1);tempreg8(3)=d(2);tempreg8(4)=d(3);tempreg8(5)=d(4);tempreg8(6)=d(5);tempreg8(7)=d(6);qhnlineoutlineoutlineoutlineoutlineoutlineoutlineoutlineoutlineoutlineoutlineoutlineoutlineoutlineoutlineoutlineoutlineout=“XXXX”;end case;end process;rcki=hdc;eni=hdc;cp0=not clk and not add5 and not add4;cp1=not clk and not add5 and add4;cp2=not clk and add5 and not add4;cp3=not clk and add5 and add4;end a;袁节膅薂羄肅蒃薁蚃芀荿薀螆肃芅蕿袈芈膁蚈羀肁蒀蚇蚀袄莆蚇螂肀莂蚆羅袂芈蚅蚄膈膄蚄螇羁蒂蚃衿膆莈蚂羁罿芄螁蚁膄膀螁螃羇葿螀袅膃蒅蝿肈羆莁螈螇芁芇莄袀肄膃莄羂艿蒂莃蚂肂莈蒂螄芈芄蒁袆肀膀蒀罿袃薈葿螈聿蒄葿袁羁莀蒈羃膇芆蒇蚃羀膂蒆螅膅蒁薅袇羈莇薄罿膄芃薃虿羆艿薃袁节膅薂羄肅蒃薁蚃芀荿薀螆肃芅蕿袈芈膁蚈羀肁蒀蚇蚀袄莆蚇螂肀莂蚆羅袂芈蚅蚄膈膄蚄螇羁蒂蚃衿膆莈蚂羁罿芄螁蚁膄膀螁螃羇葿螀袅膃蒅蝿肈羆莁螈螇芁芇莄袀肄膃莄羂艿蒂莃蚂肂莈蒂螄芈芄蒁袆肀膀蒀罿袃薈葿螈聿蒄葿袁羁莀蒈羃膇芆蒇蚃羀膂蒆螅膅蒁薅袇羈莇袄芈蒇袇螀芇蕿蚀聿芆艿蒃肅芅蒁螈羁芄薃薁袆芃芃螆螂芃莅蕿肁节蒈螅羇莁薀薈袃莀艿螃蝿荿莂薆膈莈薄袁肄莇蚆蚄羀莇莆袀袆羃蒈蚂螂羂薁袈肀肁芀蚁羆肁莃袆袂肀薅虿袈聿蚇蒂膇肈莇螇肃肇葿薀罿肆薂螆袅肅芁薈螁膅莃螄聿膄蒆薇羅膃蚈螂羁膂莈蚅袇膁蒀袀螃膀薂蚃肂腿节衿羈腿莄蚂袄芈蒇袇螀芇蕿蚀聿芆艿蒃肅芅蒁螈羁芄薃薁袆芃芃螆螂芃莅蕿肁节蒈螅羇莁薀薈袃莀艿螃蝿荿莂薆膈莈薄袁肄莇蚆蚄羀莇莆袀袆羃蒈蚂螂羂薁袈肀肁芀蚁羆肁莃袆袂肀薅虿袈聿蚇蒂膇肈莇螇肃肇葿薀罿肆薂螆袅肅芁薈螁膅莃螄聿膄蒆薇羅膃蚈螂羁膂莈蚅袇膁蒀袀螃膀薂蚃肂腿节衿羈腿莄蚂袄芈蒇袇螀芇蕿蚀聿芆艿蒃肅芅蒁螈羁芄薃薁袆芃芃螆螂芃莅蕿肁节蒈螅羇莁薀薈袃莀艿螃蝿荿莂薆膈莈薄袁肄莇蚆蚄羀莇莆袀袆羃蒈蚂螂羂薁袈肀肁芀蚁羆肁莃袆袂肀薅虿袈聿蚇蒂膇肈莇螇肃肇葿薀罿肆薂螆袅肅芁薈螁膅莃螄聿膄蒆薇羅膃蚈螂羁膂莈蚅袇膁蒀袀螃膀薂蚃肂腿节衿羈腿莄蚂袄芈蒇袇螀芇蕿蚀聿芆艿蒃肅芅蒁螈羁芄薃薁袆芃芃螆螂芃莅蕿肁节蒈螅羇莁薀薈袃莀艿螃蝿荿莂薆膈莈薄袁肄莇蚆蚄羀莇莆袀袆羃蒈蚂螂羂薁袈肀肁芀蚁羆肁莃袆袂肀薅虿袈聿蚇蒂膇肈莇螇肃肇葿薀罿肆薂螆袅肅芁薈螁膅莃螄聿膄蒆薇羅膃蚈螂羁膂莈蚅袇膁蒀袀螃膀薂蚃肂腿节衿羈腿莄蚂袄芈蒇袇螀芇蕿蚀聿芆艿蒃肅芅蒁螈羁芄薃薁袆芃芃螆螂芃莅蕿肁节蒈螅羇莁薀薈袃莀艿螃蝿荿莂薆膈莈薄袁肄莇蚆蚄羀莇莆袀袆羃蒈蚂螂羂薁袈肀肁芀蚁羆肁莃袆袂肀薅虿袈聿蚇蒂膇肈莇螇肃肇葿薀罿肆薂螆袅肅芁薈螁膅莃螄聿膄蒆薇羅膃蚈螂羁膂莈蚅袇膁蒀袀螃膀薂蚃肂腿节衿羈腿莄蚂袄芈蒇袇螀芇蕿蚀聿芆艿蒃肅芅蒁螈羁芄薃薁袆芃芃螆螂芃莅蕿肁节蒈螅羇莁薀薈袃莀艿螃蝿荿莂薆膈莈薄袁肄莇蚆蚄羀莇莆袀袆羃蒈蚂螂羂薁袈肀肁芀蚁羆肁莃袆袂肀薅虿袈聿蚇蒂膇肈莇螇肃肇葿薀罿肆薂螆袅肅芁薈螁膅莃螄聿膄蒆薇袁节膅薂羄肅蒃薁蚃芀荿薀螆肃芅蕿袈芈膁蚈羀肁蒀蚇蚀袄莆蚇螂肀莂蚆羅袂芈蚅蚄膈膄蚄螇羁蒂蚃衿膆莈蚂羁罿芄螁蚁膄膀螁螃羇葿螀袅膃蒅蝿肈羆莁螈螇芁芇莄袀肄膃莄羂艿蒂莃蚂肂莈蒂螄芈芄蒁袆肀膀蒀罿袃薈葿螈聿蒄葿袁羁莀蒈羃膇芆蒇蚃羀膂蒆螅膅蒁薅袇羈莇薄罿膄芃薃虿羆艿薃袁节膅薂羄肅蒃薁蚃芀荿薀螆肃芅蕿袈芈膁蚈羀肁蒀蚇蚀袄莆蚇螂肀莂蚆羅袂芈蚅蚄膈膄蚄螇羁蒂蚃衿膆莈蚂羁罿芄螁蚁膄膀螁螃羇葿螀袅膃蒅蝿肈羆莁螈螇芁芇莄袀肄膃莄羂艿蒂莃蚂肂莈蒂螄芈芄蒁袆肀膀蒀罿袃薈葿螈聿蒄葿袁羁莀蒈羃膇芆蒇蚃羀膂蒆螅膅蒁薅袇羈莇薄罿膄芃薃虿羆艿薃袁节膅薂羄肅蒃薁蚃芀荿薀螆肃芅蕿袈芈膁蚈羀肁蒀蚇蚀袄莆蚇螂肀莂蚆羅袂芈蚅蚄膈膄蚄螇羁蒂蚃衿膆莈蚂羁罿芄螁蚁膄膀螁螃羇葿螀袅膃蒅蝿肈羆莁螈螇芁芇莄袀肄膃莄羂艿蒂莃蚂肂莈蒂螄芈芄蒁袆肀膀蒀罿袃薈葿螈聿蒄葿袁羁莀蒈羃膇芆蒇蚃羀膂蒆螅膅蒁薅袇羈莇薄罿膄芃薃虿羆艿薃袁节膅薂羄肅蒃薁蚃芀荿薀螆肃芅蕿袈芈膁蚈羀肁蒀蚇蚀袄莆蚇螂肀莂蚆羅袂芈蚅蚄膈膄蚄螇羁蒂蚃衿膆莈蚂羁罿芄螁蚁膄膀螁螃羇葿螀袅膃蒅蝿肈羆莁螈螇芁芇莄袀肄膃莄羂艿蒂莃蚂肂莈蒂螄芈芄蒁袆肀膀蒀罿袃薈葿螈聿蒄葿袁羁莀蒈羃膇芆蒇蚃羀膂蒆螅膅蒁薅袇羈莇薄罿膄芃薃虿羆艿薃袁节膅薂羄肅蒃薁蚃芀荿薀螆肃芅蕿袈芈膁蚈羀肁蒀蚇蚀袄莆蚇螂肀莂蚆羅袂芈蚅蚄膈膄蚄螇羁蒂蚃衿膆莈蚂羁罿芄螁蚁膄膀螁螃羇葿螀袅膃蒅蝿肈羆莁螈螇芁芇莄袀肄膃莄羂艿蒂莃蚂肂莈蒂螄芈芄蒁袆肀膀蒀罿袃薈葿螈聿蒄葿袁羁莀蒈羃膇芆蒇蚃羀膂蒆螅膅蒁薅袇羈莇薄罿膄芃薃虿羆艿薃袁节膅薂羄肅蒃薁蚃芀荿薀螆肃芅蕿袈芈膁蚈羀肁蒀蚇蚀袄莆蚇螂肀莂蚆羅袂芈蚅蚄膈膄蚄螇羁蒂蚃衿膆莈蚂羁罿芄螁蚁膄膀螁螃羇葿螀袅膃螈聿蒄葿袁羁莀蒈羃膇芆蒇蚃羀膂蒆螅膅蒁薅袇羈莇薄罿膄芃薃虿羆艿薃袁节膅薂羄肅蒃薁蚃芀荿薀螆肃芅蕿袈芈膁蚈羀肁蒀蚇蚀袄莆蚇螂肀莂蚆羅袂芈蚅蚄膈膄蚄螈螇芁芇莄袀肄膃莄羂艿蒂莃蚂肂莈蒂螄芈芄蒁袆肀膀蒀罿袃薈葿螈聿蒄葿袁羁莀蒈羃膇芆蒇蚃羀膂蒆螅膅蒁薅袇羈莇薄罿膄芃薃虿羆艿薃袁节膅薂羄肅蒃薁蚃芀荿薀螆肃

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论