//=========================================================
// tm1640 start program
//=========================================================
void tm1640_start(void)
{
tm1640sclk_off();
tm1640data_on();
tm1640sclk_on();
delay(5);
tm1640data_off();
delay(5);
tm1640sclk_off();
delay(5);
}
//=========================================================
// tm1640 stop program
//=========================================================
void tm1640_stop(void)
{
tm1640sclk_off();
tm1640data_off();
tm1640sclk_on();
delay(5);
tm1640data_on();
delay(5);
}
//=========================================================
// tm1640 sendbyte program
//=========================================================
void tm1640_sendbyte(unsigned char m_data)
{
unsigned char i;
tm1640data_off();
tm1640sclk_off();
for(i = 0; i < 8; i++)
{
tm1640sclk_off();
if(m_data & 0x01)
{
tm1640data_on();
delay(5);
}
else
{
tm1640data_off();
delay(5);
}
tm1640sclk_on();
m_data >>= 1;
}
delay(5);
}
//=========================================================
// clear tm1640 program
//=========================================================
void tm1640_clear(void)
{
unsigned char i;
tm1640_start();
tm1640_sendbyte(0x40);
tm1640_stop();
tm1640_start();
tm1640_sendbyte(0xc0);
for(i = 0; i < 16; i++)
{
tm1640_sendbyte(0x00);
}
tm1640_stop();
tm1640_start();
tm1640_sendbyte(0x8f);
tm1640_stop();
}
//=========================================================
// tm1640 write program
//=========================================================
void write_tm1640(void)
{
unsigned char i;
tm1640_start();
tm1640_sendbyte(0x40);
//tm1640_sendbyte(0x44);
tm1640_stop();
tm1640_start();
tm1640_sendbyte(0xc0);
for(i = 0;i < 15;i++)
{
tm1640_sendbyte(g_dis_buf[i]);
}
tm1640_stop();
/*
tm1640_start();
tm1640_sendbyte(0xc0);
tm1640_sendbyte(g_dis_buf[0]);
tm1640_stop();
tm1640_start();
tm1640_sendbyte(0xc1);
tm1640_sendbyte(g_dis_buf[1]);
tm1640_stop();
tm1640_start();
tm1640_sendbyte(0xc2);
tm1640_sendbyte(g_dis_buf[2]);
tm1640_stop();
tm1640_start();
tm1640_sendbyte(0xc3);
tm1640_sendbyte(g_dis_buf[3]);
tm1640_stop();
tm1640_start();
tm1640_sendbyte(0xc4);
tm1640_sendbyte(g_dis_buf[4]);
tm1640_stop();
tm1640_start();
tm1640_sendbyte(0xc5);
tm1640_sendbyte(g_dis_buf[5]);
tm1640_stop();
tm1640_start();
tm1640_sendbyte(0xc6);
tm1640_sendbyte(g_dis_buf[6]);
tm1640_stop();
tm1640_start();
tm1640_sendbyte(0xc7);
tm1640_sendbyte(g_dis_buf[7]);
tm1640_stop();
tm1640_start();
tm1640_sendbyte(0xc8);
tm1640_sendbyte(g_dis_buf[8]);
tm1640_stop();
tm1640_start();
tm1640_sendbyte(0xc9);
tm1640_sendbyte(g_dis_buf[9]);
tm1640_stop();
tm1640_start();
tm1640_sendbyte(0xca);
tm1640_sendbyte(g_dis_buf[10]);
tm1640_stop();
tm1640_start();
tm1640_sendbyte(0xcb);
tm1640_sendbyte(g_dis_buf[11]);
tm1640_stop();
tm1640_start();
tm1640_sendbyte(0xcc);
tm1640_sendbyte(g_dis_buf[12]);
tm1640_stop();
tm1640_start();
tm1640_sendbyte(0xcd);
tm1640_sendbyte(g_dis_buf[13]);
tm1640_stop();
tm1640_start();
tm1640_sendbyte(0xce);
tm1640_sendbyte(g_dis_buf[14]);
tm1640_stop();
tm1640_start();
tm1640_sendbyte(0xcf);
tm1640_sendbyte(g_dis_buf[15]);
tm1640_stop();
*/
tm1640_start();
tm1640_sendbyte(0x8f);
tm1640_stop();
}
TM1640数码管驱动程序 以验证非常好用
需积分: 10 63 浏览量
2016-05-01
23:38:55
上传
评论
收藏 606B ZIP 举报
业精于勤818
- 粉丝: 0
- 资源: 5