4、好了,主要是完成断码屏的驱动部分,根据HT1621芯片的规格书编写即可,大家有兴趣的可以网上搜索规格书或者相关历程,我这里只是呈上少部分驱动程序,如下:
void Ht1621Wr_Data(unsigned char Data,unsigned char cnt)
{
unsigned char i;
for (i=0;i
{
gd_eval_led_off(LED3);
gd_eval_led_off(LED4);
if((Data & 0x80)==0x80)
{
gd_eval_led_on(LED5);
}
else
{
gd_eval_led_off(LED5);
}
Delay(10);
gd_eval_led_on(LED4);
Data<<=1;
}
}
void Ht1621WrCmd(unsigned char Cmd)
{
gd_eval_led_off(LED3);
Ht1621Wr_Data(0x80,4);
Ht1621Wr_Data(Cmd,8);
gd_eval_led_on(LED3);
}
void Ht1621WrOneData(unsigned char Addr,unsigned char Data)
{
gd_eval_led_off(LED3);
Ht1621Wr_Data(0xa0,3);
Ht1621Wr_Data(Addr<<2,6);
Ht1621Wr_Data(Data,4);
gd_eval_led_on(LED3);
Delay(10);
}
void Ht1621WrAllData(unsigned char Addr,unsigned char *p,unsigned char cnt)
{
unsigned char i;
gd_eval_led_off(LED3);
Ht1621Wr_Data(0xa0,3);
Ht1621Wr_Data(Addr<<2,6);
for (i=0;i
{
Ht1621Wr_Data(*p,8);
p++;
}
gd_eval_led_on(LED3);
}
void Ht1621_Clear(unsigned char Addr,unsigned char cnt)
{
Ht1621WrAllData(Addr,Ht1621Tab,cnt);
}
void Ht1621_Init(void)
{
Ht1621WrCmd(BIAS);
Ht1621WrCmd(RC256);
//Ht1621WrCmd(XTAL);
Ht1621WrCmd(SYSDIS);
Ht1621WrCmd(WDTDIS1);
Ht1621WrCmd(SYSEN);
Ht1621WrCmd(LCDON);
}
5、好了,驱动已编写完毕,付个main程序吧,其实对原demo程序修改的很少,只是增加了3个IO口和HT1621的驱动子程序,操控一点不复杂,因这里只是演示,就简单把断码屏全显示了,看看效果:
int main(void)
{
/* ini
tialize KEY and LED, configure SysTick */
gd_eval_key_init(KEY_USER, KEY_MODE_EXTI);
systick_config();
gd_eval_led_init(LED1);
gd_eval_led_init(LED2);
gd_eval_led_init(LED3);
gd_eval_led_init(LED4);
gd_eval_led_init(LED5);
Ht1621_Init();
delay_1ms(250);
/* flash the LED for test */
led_flash(1);
Ht1621WrAllData(14,LCD_BUFFER,9); while(1){
}
}
结束,整体操作还OK,欢迎大家互相交流~~
`