#define HT1632_SYSEN 0x01//ϵͳʹÄÜ
#define HT1632_SYSDIS 0x00//ʹÄܹأ¬Õâ¸öÒª¹Øµô£¬Èô¿ªÔòLEDÈ«Ãð
#define HT1632_OPTION 0x24//N-MOS OUTPUT and 16*24 (8-com 0x20)
#define HT1632_LEDON 0x03//LEDON
#define HT1632_LEDOFF 0x02//LEDOFF
#define HT1632_BLINKOFF 0x08//ÉÁ˸¹Ø
#define HT1632_BLINKON 0x09//ÉÁ˸¿ª
#define HT1632_PWMDUTY 0xaa
#define HT1632_SLAVE 0x10//ÉèΪ´Óģʽ
#define HT1632_MASTER 0x18//ÉèΪÖ÷ģʽ
#define HT1632_Data PAout(4)//HT1632数据传送
#define HT1632_WR PAout(5)//HT1632写控制
#define HT1632_RD PAout(10)//HT1632读控制
#define HT1632_CS PAout(11)//HT1632片选
void HT1632_Init(void)//³õʼ»¯HT1632
{
HT1632_CS=0;
Write_Command();
//Write_8Bit(HT1632_SYSDIS);
Write_8Bit(0x01);//ÉèÖÃHT1632µÄ¹¤×÷ģʽΪ16*24
Write_8Bit(0x20);//ÉèÖÃΪÖ÷ģʽ£¬Æ¬ÄÚRCÕñµ´Æ÷
Write_8Bit(0x03);//¹Ø±ÕDISʹÄÜDelay2(10);
Write_8Bit(0x08);//ϵͳ¹¤×÷ʹÄÜ¿ª
//Write_8Bit(0xaf);
//Write_8Bit(0xaa);
//Clear_SetHT1632(0);
//Clear_SetHT1632(1);
HT1632_CS=1;
}
void Write_Command(void)//дÃüÁîÍ·ÈýλÊý¾Ý100
{
HT1632_WR =0;
Delay1();
HT1632_Data=1;
Delay1();
HT1632_WR=1;
Delay1();
HT1632_WR=0;
Delay1();
HT1632_Data=0;
Delay1();
HT1632_WR=1;
Delay1();
HT1632_Data=0;
Delay1();
HT1632_WR=1;
}
void Data_Command(void)//дÊý¾ÝÇ°ÈýλÊý¾Ý101
{
HT1632_WR =0;
Delay1();
HT1632_Data=1;
Delay1();
HT1632_WR=1;
Delay1();
HT1632_WR=0;
Delay1();
HT1632_Data=0;
Delay1();
HT1632_WR=1;
Delay1();
HT1632_WR =0;
Delay1();
HT1632_Data=1;
Delay1();
HT1632_WR=1;
Delay1();
}
void Write_8Bit(u8 x)//д8λÊý¾Ý½øHT1632
{
u8 i,k;
k=0x80;
for(i=0;i<8;i++)
{
HT1632_WR=0;
Delay1();
if((k&x)==0)HT1632_Data=0;
else HT1632_Data=1;
Delay1();
HT1632_WR=1;
k<<=1;//ÏÈд¸ßλ
}
HT1632_WR=1;
Delay1();Delay1();
Delay1();//Öмä¿ÕÂö³å£¬Ê±ÐòÒªÇó£¬ÒòΪÃüÁîµÚ¾ÅλÊÇX
HT1632_WR=0;
}
void Write_Rom_add(u8 y)//дROMµØÖ·
{
u8 i,k;
k=0x40;
for(i=0;i<7;i++)
{
if((k&y)==0)HT1632_Data=0;
else HT1632_Data=1;
HT1632_WR=0;
Delay1();Delay1();
HT1632_WR=1;
k<<=1;
}
}
void Write_Rom_Data(u8 z)//дROMÊý¾Ý
{
u8 i,k;
k=0x01;
for(i=0;i<8;i++)
{
if((k&z)==0)HT1632_Data=0;
else HT1632_Data=1;
HT1632_WR=0;
Delay1();Delay1();
HT1632_WR=1;
k>>=1;
}
}
void set_guo(u8 *pp)
{
u8 i;
for(i=0;i<7;i++)
{
Write_Rom_Data(*pp);
pp++;
}
}
我用这个程序驱动HT1632 显示用,可怎么就驱动不了呢,哪位大侠给指点一下迷津,不胜感激!
|