这是程序,麻烦看一下,我看了好几遍不知道哪里会有问题,单片机是STC12的
void main(void)
{
uchar k = 0;
P2M0 = 0xff;
P2M1 = 0x00;
Ht1621Init();
InitTimer1();//10ms中断
DelaymS(1000);
for(k = 0;k < 32;k ++)//清屏
{
Ht1621WrOneData(k,0);
}
DelaymS(1000);
Ht1621WrOneData(0x00,0x08);
Ht1621WrOneData(0x01,0x01);
Ht1621WrOneData(0x02,0x0f);
Ht1621WrOneData(0x03,0x0e);
Ht1621WrOneData(0x04,0x0e);
Ht1621WrOneData(0x05,0x08);
Ht1621WrOneData(0x06,0x0f);
Ht1621WrOneData(0x0a,0x0f);
Ht1621WrOneData(0x0b,0x0f);
Ht1621WrOneData(0x0c,0x0f);
//两边颜色条全亮
Ht1621WrOneData(7,0x0f);
Ht1621WrOneData(8,0x0f);
Ht1621WrOneData(9,0x0f);
Ht1621WrOneData(17,0x0f);
Ht1621WrOneData(18,0x0f);
Ht1621WrOneData(19,0x0f);
//显示两个0
DispDigital(0,0);
DispDigital(1,0);
while(1)
{
if(j > 0)//10ms扫描一次
{
j = 0;
k ++;
if(k > 50)//500ms闪烁计数
{
k = 0;
i ++;
}
if(i > 3) i = 0;
//三个颜色条一起转动
Ht1621WrOneData(10,0x01 << i);
Ht1621WrOneData(11,0x01 << i);
Ht1621WrOneData(12,0x01 << i);
//500ms闪烁笔段
if(i % 2 == 0)
{
Ht1621WrOneData(6,0x0f);
Ht1621WrOneData(4,0x0f);
Ht1621WrOneData(2,0x0f);
}
else
{
Ht1621WrOneData(6,0x0b);
Ht1621WrOneData(4,0x0e);
Ht1621WrOneData(2,0x0e);
}
}
}
}
void Timer1Interrupt(void) interrupt 3//10Ms中断
{
TH1 = 0xB8;
TL1 = 0x00;
j ++;
}
显示屏数据,COM端分别是1,2,4,8 SEG段是1~19
如图
|