msp430+2553+ht1621b显示闪烁问题
请问怎么解决ht1621b显示闪烁,不清楚的问题?
1.HT1621电压稳定;
2.2553刷HT1621的时候,不要刷的太快!它内部带缓存的.
3.看看你的初始化,有没有问题!对比度的设置。
回复 沙发cat3902982 的帖子
下面是我根据例程自己修改的一段代码,我显示的位数不同,1621闪烁的频率还不一样。
麻烦大神了、、、、
- //-----------------------------------------------------------------------------------------
- // msp430g2553 ht1621_lcd test
- //-----------------------------------------------------------------------------------------
- #include "msp430g2553.h"
- #include
- #define uint unsigned int
- #define uchar unsigned char
- #define BIAS 0x52 //0b1000 0101 0010 1/3duty 4com
- #define SYSDIS 0X00 //0b1000 0000 0000 关振系统荡器和LCD偏压发生器
- #define SYSEN 0X02 //0b1000 0000 0010 打开系统振荡器
- #define LCDOFF 0X04 //0b1000 0000 0100 关LCD偏压
- #define LCDON 0X06 //0b1000 0000 0110 打开LCD偏压
- #define XTAL 0x28 //0b1000 0010 1000 外部接时钟
- #define RC256 0X30 //0b1000 0011 0000 内部时钟
- #define TONEON 0X12 //0b1000 0001 0010 打开声音输出
- #define TONEOFF 0X10 //0b1000 0001 0000 关闭声音输出
- #define WDTDIS1 0X0A //0b1000 0000 1010 禁止看门狗
- ////////////////////////////////////////////////////////////////////////////////
- void Ht1621_GND_0() { P1OUT &= ~0x10;} // define P1.4 ---> GND_power
- void Ht1621_GND_1() { P1OUT |= 0x10;}
- void Ht1621_VCC_0() { P1OUT &= ~0x20;} // define P1.5 ---> VCC_power
- void Ht1621_VCC_1() { P1OUT |= 0x20;}
- void Ht1621_CS_0() { P2OUT &= ~0x04;} // define P2.2 ---> CS
- void Ht1621_CS_1() { P2OUT |= 0x04;}
- void Ht1621_WR_0() { P2OUT &= ~0x02;} // define P2.1 ---> WR
- void Ht1621_WR_1() { P2OUT |= 0x02;}
- void Ht1621_DO_0() { P2OUT &= ~0x01;} // define P2.0 ---> DAT
- void Ht1621_DO_1() { P2OUT |= 0x01;}
- ////////////////////////////////////////////////////////////////////////////////
- //-----------------------------------------------------------------------------------------
- //函数名称:Delay()
- //功 能:延时子程序
- //-----------------------------------------------------------------------------------------
- void Delay(uchar us) //5,7,9
- {
- while(--us);
- }
- //-----------------------------------------------------------------------------------------
- //函数名称:Delayms()
- //-----------------------------------------------------------------------------------------
- void Delayms(uint ims)
- {
- uint i,j;
- for(i=0;i
- for(j=0;j<65;j++) { Delay(1); }
- }
- //-----------------------------------------------------------------------------------------
- //函数名称:Ht1621Wr_Data()
- //-----------------------------------------------------------------------------------------
- void Ht1621Wr_Data(uchar Data,uchar cnt)
- {
- uchar i;
- for (i=0;i
- {
- Ht1621_WR_0();
- if((Data & 0x80)==0x80) { Ht1621_DO_1(); }
- else { Ht1621_DO_0(); }
- Ht1621_WR_1();
- Data<<=1;
- }
- }
- //-----------------------------------------------------------------------------------------
- //函数名称:void Ht1621WrCmd(uchar Cmd)
- //-----------------------------------------------------------------------------------------
- void Ht1621WrCmd(uchar Cmd)
- {
- Ht1621_CS_0(); //CS
- Ht1621Wr_Data(0x80,4); //写入命令标志100
- Ht1621Wr_Data(Cmd,8); //写入命令数据
- Ht1621_CS_1();
- }
- //-----------------------------------------------------------------------------------------
- //函数名称:void Ht1621WrOneData(uchar Addr,uchar Data)
- //-----------------------------------------------------------------------------------------
- void Ht1621WrOneData(uchar Addr,uchar Data)
- {
- Ht1621_CS_0();
- Ht1621Wr_Data(0xa0,3); //写入数据标志101
- Ht1621Wr_Data(Addr<<2,6); //写入地址数据
- Ht1621Wr_Data(Data<<4,4); //写入数据
- Ht1621_CS_1();
- }
- //-----------------------------------------------------------------------------------------
- //函数名称:void Ht1621WrAllData()
- //-----------------------------------------------------------------------------------------
- void Ht1621WrAllData(void)
- {
- uchar i;
- Ht1621_CS_0();
- Ht1621Wr_Data(0xa0,3); //写入数据标志101
- Ht1621Wr_Data(0x00<<2,6); //写入地址数据
- for (i=0;i<16;i++) { Ht1621Wr_Data(0x00,8); }
- Ht1621_CS_1();
- }
- //-----------------------------------------------------------------------------------------
- //函数名称:void Ht1621_Init(void)
- //-----------------------------------------------------------------------------------------
- void Ht1621_Init(void)
- {
- Ht1621_CS_0();
- Ht1621_WR_0();
- Ht1621_DO_0();
- Delay(100); //延时使LCD工作电压稳定
- Ht1621WrCmd(BIAS);
- Ht1621WrCmd(RC256); //使用内部振荡器
- Ht1621WrCmd(SYSDIS);
- Ht1621WrCmd(WDTDIS1);
- Ht1621WrCmd(SYSEN);
- Ht1621WrCmd(LCDON);
- }
- //-----------------------------------------------------------------------------------------
- //函数名称:Initial()
- //功 能:初始化子程序
- //-----------------------------------------------------------------------------------------
- void Initial(void)
- {
- WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
- P1DIR = 0xFF; // All P1.x outputs
- P1OUT = 0; // All P1.x reset
- P2DIR = 0xFF; // All P2.x outputs
- P2OUT = 0; // All P2.x reset
- }
- void writep(uchar t)
- {
- Ht1621WrOneData(7,t);
- }
- void write1(uchar t)
- {
- Ht1621WrOneData(1,t);
- Ht1621WrOneData(2,t);
- }
- void write2(uchar t)
- {
- Ht1621WrOneData(0,t);
- Ht1621WrOneData(1,t);
- Ht1621WrOneData(3,t);
- Ht1621WrOneData(4,t);
- Ht1621WrOneData(6,t);
- }
- void write3(uchar t)
- {
- Ht1621WrOneData(0,t);
- Ht1621WrOneData(1,t);
- Ht1621WrOneData(2,t);
- Ht1621WrOneData(3,t);
- Ht1621WrOneData(6,t);
- }
- void write6(uchar t)
- {
- Ht1621WrOneData(0,t);
- Ht1621WrOneData(2,t);
- Ht1621WrOneData(3,t);
- Ht1621WrOneData(4,t);
- Ht1621WrOneData(5,t);
- Ht1621WrOneData(6,t);
- }
- void write8(uchar t)
- {
- Ht1621WrOneData(0,t);
- Ht1621WrOneData(1,t);
- Ht1621WrOneData(2,t);
- Ht1621WrOneData(3,t);
- Ht1621WrOneData(4,t);
- Ht1621WrOneData(5,t);
- Ht1621WrOneData(6,t);
- }
- //-----------------------------------------------------------------------------------------
- //函数名称:main()
- //-----------------------------------------------------------------------------------------
- void main(void)
- {
- uchar i,j,t,x,y,z;
- Initial(); //初始化子程序
- Ht1621_GND_0(); //HT1621 power on
- Ht1621_VCC_1();
- Ht1621_Init(); //上电初始化LCD
- Delay(100
- ); //延时一段时间
- Ht1621WrAllData();
- while(1)
- {
- Ht1621_Init(); //上电初始化LCD
- //Delayms(50); //延时一段时间
- Ht1621WrAllData();
- t=0x08;
- write2(t);
- t=0x04;
- write6(t);
- t=0x04;
- writep(t);
- t=0x02;
- write8(t);
- t=0x01;
- writep(t);
- }
- }
你试试为HT1621外接个晶振,初始化的时候配时钟源的时候 Ht1621WrCmd(RC256);改为 Ht1621WrCmd(XTAL);
能把历程发给我看一下不,谢谢,邮箱是
1042568249@qq.com
有IC驱动程序可以提供, 完美替代兼容HT1621B SSOP48 LQFP48 LQFP44 DIP28
QQ 191 888 5898
联系人:许先生 QQ:1918885898 电话:18898582398 免费样品赠送,工程技术支持,PDF产品资料提供!