DullBoy123
巨白!
2021-01-17 18:30

TM1620数码管驱动

  • c语言
#include<1620.h>
#include<stc15.h>
#include<intrins.h>


#define   disMode 0x00        //模式选择
#define   dtOrd   0x40
#define   disCon  0x80
#define   adrOrd  0x84

//disMode config
#define   four_du 0x00
#define   five_du 0x01
#define   six_du  0x02


//dataOrd
#define adrAdd  0x40
#define adrFix  0x44

//disCon_Ord
#define bright_close  0x80
#define bright_level1 0x88
#define bright_level2 0x89
#define bright_level3 0x8A
#define bright_level4 0x8B
#define bright_level5 0x8C
#define bright_level6 0x8D
#define bright_level7 0x8E
#define bright_level8 0x8F

//adrMod_con
#define adr00H 0xC0
#define adr01H 0xC1
#define adr02H 0xC2
#define adr03H 0xC3
#define adr04H 0xC4
#define adr05H 0xC5
#define adr06H 0xC6
#define adr07H 0xC7
#define adr08H 0xC8
#define adr09H 0xC9
#define adr0AH 0xCA
#define adr0BH 0xCB



void Delay2us()		//@11.0592MHz
{
	unsigned char i;

	i = 3;
	while (--i);
}




static u8  LED_tab[11]={  // 定义数码管0~9数字码表
0x3f,    //0B00111111,       //0
0x30,    //0B00000110,       //1
0x6d,    //0B01011011,         //2
0x79,    //0B01001111,         //3
0x33,    //0B01100110,         //4
0x5b,    //0B01101101,         //5
0x5f,    //0B01111101,         //6
0x70,    //0B00000111,         //7
0x7f,    //0B01111111,         //8
0x7B,    //0B01101111,         //9
0x4f,                         //E                                               
};
void Delay1ms()  //@24.000MHz
{
 unsigned char i, j;

 i = 24;
 j = 85;
 do
 {
  while (--j);
 } while (--i);
}




void tm1620_write(u8 dt)
{
	 u8 i;
	 STB = 0;
	 for(i=0;i<8;i++)
	{
		CLK = 0;
		if(dt&0x01)DIN = 1;
		else DIN = 0;
		dt >>= 1;
		Delay1ms();
		CLK = 1;
		Delay1ms();
	}
}
void tm1620_init()
{
	 tm1620_write(six_du);
	 STB = 1;
		Delay2us();
	 tm1620_write(adrFix);
	 STB = 1;
		Delay2us();
	 tm1620_write(adr00H);
	 tm1620_write(0x3f);
	 STB = 1;
		Delay2us();
	 tm1620_write(adr02H);
	 tm1620_write(0x3f);
	 STB = 1;
		Delay2us();
	 tm1620_write(adr04H);
	 tm1620_write(0x3f);
	 STB = 1;
		Delay2us();
	 tm1620_write(adr06H);
	 tm1620_write(0x3f);
	 STB = 1;
		Delay2us();
	 tm1620_write(bright_level3);
 }



请大哥帮忙看一下 这个程序始终点不亮数码管

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

0条回答