完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我想用一个数组显示0-9个数字,但是由于本人是菜鸟又没接触过ht1621,在网上下了个测试程序,现在可以把lcd每段都点亮,程序不是很能看懂,我想用一个数组显示0-9,我的lcd是4com 9seg下面是程序,请高手指点怎么修改。谢谢啦/*------------------------------------------------------------------------------MEASURE.C: Remote Measurement Recorder using the C51 COMPILER
Copyright 1990-2005 Keil Software, Inc. ------------------------------------------------------------------------------*/ #include /* special function register declarations */ /* for the Philips P89C935 device */ #include /* standard I/O .h-file */ #include /* standard library .h-file */ #include /* character functions */ #include #define uchar unsigned char #define uint unsigned int #define _Nop() _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_() #define BIAS 0x50 //0X52 1/3ƫѹ,4±³¼« 0x50 1/2ƫѹ, #define SYSDIS 0X00 //¹Ø±ÕϵͳÕñµ´Æ÷ºÍLCDƫѹ·¢ÉúÆ÷ #define SYSEN 0X02 #define LCDOFF 0X04 //¹Ø±Õƫѹ·¢ÉúÆ÷ #define LCDON 0X06 //´ò¿ªÆ«Ñ¹·¢ÉúÆ÷ #define XTAL 0x28 //ϵͳʱÖÓÔ´ ¾§Õñ #define RC256 0X30 //ƬÄÚRCÕñµ´ #define TONEON 0X12 //´ò¿ªÉùÒô #define TONEOFF 0X10 //¹Ø±ÕÉùÒô #define WDTDIS 0X0A //½ûÖ¹¿´ÃŹ· ***it HT1621_DAT=P1^5; //´®ÐÐÊý¾ÝÊäÈë/Êä³ö ***it HT1621_CS=P1^1; //ƬѡÊäÈë ***it HT1621_WR=P1^3; //Âö³åÊäÈë ***it cs_sda = P3^5; //dog uchar code Ht1621Tab[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; void Delay(uchar us) { while(--us); } void DelayMS(uint iMs) { uint i,j; for(i=0;ifor(j=0;j<65;j++) Delay(1); } void Ht1621Wr_Data(uchar Data,uchar cnt) { uchar i; for (i=0;i{ HT1621_WR=0; _Nop(); HT1621_DAT=Data&0x80; _Nop(); HT1621_WR=1; _Nop(); Data<<=1; } } void Ht1621WrCmd(uchar Cmd) { HT1621_CS=0; _Nop(); Ht1621Wr_Data(0x80,4); Ht1621Wr_Data(Cmd,8); HT1621_CS=1; _Nop(); } void Ht1621WrOneData(uchar Addr,uchar Data) { HT1621_CS=0; Ht1621Wr_Data(0xa0,3); Ht1621Wr_Data(Addr<<2,6); Ht1621Wr_Data(Data<<4,4); HT1621_CS=1; _Nop(); } void Ht1621WrAllData(uchar Addr,uchar *p,uchar cnt) { uchar i; HT1621_CS=0; Ht1621Wr_Data(0xa0,3); Ht1621Wr_Data(Addr<<2,6); for (i=0;i{ Ht1621Wr_Data(*p,8); p++; } HT1621_CS=1; _Nop(); } void Ht1621_Init(void) { HT1621_CS=1; HT1621_WR=1; HT1621_DAT=1; DelayMS(2000); cs_sda = ~cs_sda ;// Ht1621WrCmd(BIAS); Ht1621WrCmd(RC256); Ht1621WrCmd(SYSDIS); Ht1621WrCmd(WDTDIS); Ht1621WrCmd(SYSEN); Ht1621WrCmd(LCDON); } void main() { uchar i,j,t; Ht1621_Init(); //Éϵç³õʼ»¯LCD cs_sda = ~cs_sda ; while(1){ Ht1621WrAllData(0,Ht1621Tab,16); //ÇåÆÁHt1621WrAllData(0,Ht1621Tab,16); for (i=0;i<32;i++) { t=0x01; for (j=0;j<4;j++) { Ht1621WrOneData(i,t); t<<=1; t++; DelayMS(200); cs_sda = ~cs_sda ;// } } } } |
|
相关推荐
1个回答
|
|
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 16:47 , Processed in 0.626840 second(s), Total 71, Slave 55 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号