` 本帖最后由 liu1032042013 于 2015-1-2 16:56 编辑
单片机用的是ti的Launchpad msp430,点阵是8*8点阵,驱动芯片是两个74HC595;视频连接:http://pan.baidu.com/s/1c0gu620 原理图见附件
#include
const unsigned char tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
const unsigned char digittab[10][8]={ //字模取模方式 阴码 逆向 逐列式
{0x7C,0x55,0x5F,0x45,0x5F,0x55,0x7C,0x00},/*"西",0*/
{0x16,0x12,0xB2,0x5B,0xB6,0x12,0x12,0x16},/*"安",1*/
{0x7C,0x54,0x7F,0x54,0x7C,0xFE,0x2A,0x3E},/*"邮",2*/
{0x00,0x3E,0x2A,0xFF,0xAA,0xBE,0xC0,0x00},/*"电",3*/
{0x44,0x24,0x14,0x0F,0x14,0x24,0x44,0x00},/*"大",4*/
{0x06,0x23,0xAA,0xAB,0xFA,0x23,0x22,0x06},/*"学",5*/
{0x00,0x00,0x3E,0x49,0x49,0x32,0x00,0x00},/*"6",6*/
{0x00,0x00,0x03,0x71,0x09,0x07,0x00,0x00},/*"7",7*/
{0x00,0x00,0x36,0x49,0x49,0x36,0x00,0x00},/*"8",8*/
{0x00,0x00,0x26,0x49,0x49,0x3E,0x00,0x00},/*"9",9*/
};
unsigned int timecount;
unsigned char cnta;
unsigned char cntb;
#define SD_H P1OUT|=BIT4; //串行数据输入
#define SD_L P1OUT&=~BIT4;
#define ST_H P1OUT|=BIT5; //存储寄存器时钟输入
#define ST_L P1OUT&=~BIT5;
#define SH_H P1OUT|=BIT6; //移位寄存器时钟输入
#define SH_L P1OUT&=~BIT6;
void Ser_IN(unsigned char Data)
{
unsigned char i;
for(i=0; i < 8; i++)
{
SH_L; //CLOCK_MAX=100MHz
if(Data&0x80)
{
SD_H;
}
else
{
SD_L;
}
Data <<= 1;
SH_H;
}
}
void Par_OUT(void)
{
ST_L;
ST_H;
}
void sysclock()
{
TACTL=TASSEL0+TACLR;
CCTL0=CCIE;
CCR0=2000;
TACTL|=MC0;
_EINT();
//LPM0;
}
void main()
{
WDTCTL=WDTPW+WDTHOLD;
P1SEL&=~(BIT4+BIT5+BIT6);
P1DIR|=BIT4+BIT5+BIT6;
sysclock();
while(1)
{
Ser_IN(tab[cnta]);//8X8点阵列扫描
Ser_IN(digittab[cntb][cnta]);//8X8点阵行送扫描数据
Par_OUT();//74HC595输出显示
cnta++;
if(cnta==8)
{
cnta=0;
}
}
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void timeA0(void)
{
// Ser_IN(tab[cnta]);//8X8点阵列扫描
//Ser_IN(digittab[cntb][cnta]);//8X8点阵行送扫描数据
//Par_OUT();//74HC595输出显示
//cnta++;
timecount++;
if(timecount==1)
{
timecount=0;
cntb++;
if(cntb==6)
{
cntb=0;
}
}
}
`
|