#include
void _delay()
{
unsigned int i,j;
for(i=0;i<=5000;i++)
{
for(j=0;j<=5;j++);
}
}
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
P1DIR=P1DIR|0xFF;
static unsigned int a[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,
0xa1,0x86,0x8e,0x8c,0xc1,0x91,0x00};
unsigned int x;
for(;;)
{
for(x=0;x<=16;x++)
{
P1OUT=a[x];
_delay();
}
}
}
MSP430實(shí)現(xiàn)MAX7219顯示程序(匯編)
#include "msp430x41x.h"
DIN EQU 001H ;P1.0
CLK EQU 002H ;P1.1
LOAD EQU 004H ;P1.2
ORG 0F000H
RESET MOV #300H,SP ;初始化
MOV #WDTPW+WDTHOLD,&WDTCTL
BIS.B #CLK,&P1DIR
BIS.B #DIN,&P1DIR
BIS.B #LOAD,&P1DIR
PUSH #00C01H ;設(shè)置工作模式
BIC.B #LOAD,&P1OUT
CALL #MOVE
BIS.B #LOAD,&P1OUT
PUSH #00B05H ;設(shè)置掃描位數(shù)
BIC.B #LOAD,&P1OUT
CALL #MOVE
BIS.B #LOAD,&P1OUT
PUSH #009FFH ;設(shè)置編碼方式
BIC.B #LOAD,&P1OUT
CALL MOVE
BIS.B #LOAD,&P1OUT
PUSH #00A07H ;設(shè)置亮度
BIC.B #LOAD,&P1OUT
CALL MOVE
BIS.B #LOAD,&P1OUT
XIAN PUSH #00107H ;顯示第一位
BIC.B #LOAD,&P1OUT
CALL MOVE
BIS.B #LOAD,&P1OUT
PUSH #00206H ;顯示第二位
BIC.B #LOAD,&P1OUT
CALL MOVE
BIS.B #LOAD,&P1OUT
PUSH #00305H ;顯示第三位
BIC.B #LOAD,&P1OUT
CALL MOVE
BIS.B #LOAD,&P1OUT
PUSH #00404H ;顯示第四位
BIC.B #LOAD,&P1OUT
CALL MOVE
BIS.B #LOAD,&P1OUT
PUSH #00503H ;顯示第五位
BIC.B #LOAD,&P1OUT
CALL MOVE
BIS.B #LOAD,&P1OUT
PUSH #00602H ;顯示第六位
BIC.B #LOAD,&P1OUT
CALL MOVE
BIS.B #LOAD,&P1OUT
JMP $
MOVE MOV.B #16,R6
MOV 2(SP),R13
MOV #1,R10
SENDLOOP BIC.B #CLK,&P1OUT
BIT R10,R13
JNZ SEND1
SEND0 BIC.B #DIN,&P1OUT
JMP GOON
SEND1 BIS.B #DIN,&P1OUT
GOON BIS.B #CLK,&P1OUT
RLA R10
BIC.B #CLK,&P1OUT
DEC R6
JNZ SENDLOOP
RET
ORG 0FFFEH
DW RESET
END#include "msp430x41x.h"
DIN EQU 001H ;P1.0
CLK EQU 002H ;P1.1
LOAD EQU 004H ;P1.2
ORG 0F000H
MOV #300H,SP ;初始化
MOV #WDTPW+WDTHOLD,&WDTCTL
BIS.B #CLK,&P1DIR
BIS.B #DIN,&P1DIR
BIS.B #LOAD,&P1DIR
PUSH #00C01H ;設(shè)置工作模式
BIC.B #LOAD,&P1OUT
CALL #MOVE
BIS.B #LOAD,&P1OUT
PUSH #00B05H ;設(shè)置掃描位數(shù)
BIC.B #LOAD,&P1OUT
CALL #MOVE
BIS.B #LOAD,&P1OUT
PUSH #009FFH ;設(shè)置編碼方式
BIC.B #LOAD,&P1OUT
CALL MOVE
BIS.B #LOAD,&P1OUT
PUSH #00A07H ;設(shè)置亮度
BIC.B #LOAD,&P1OUT
CALL MOVE
BIS.B #LOAD,&P1OUT
XIAN PUSH #00107H ;顯示第一位
BIC.B #LOAD,&P1OUT
CALL MOVE
BIS.B #LOAD,&P1OUT
PUSH #00206H ;顯示第二位
BIC.B #LOAD,&P1OUT
CALL MOVE
BIS.B #LOAD,&P1OUT
PUSH #00305H ;顯示第三位
BIC.B #LOAD,&P1OUT
CALL MOVE
BIS.B #LOAD,&P1OUT
PUSH #00404H ;顯示第四位
BIC.B #LOAD,&P1OUT
CALL MOVE
BIS.B #LOAD,&P1OUT
PUSH #00503H ;顯示第五位
BIC.B #LOAD,&P1OUT
CALL MOVE
BIS.B #LOAD,&P1OUT
PUSH #00602H ;顯示第六位
BIC.B #LOAD,&P1OUT
CALL MOVE
BIS.B #LOAD,&P1OUT
JMP $
MOVE MOV.B #16,R6
POP R13
MOV #1,R10
SENDLOOP BIC.B #CLK,&P1OUT
BIT R10,R13
JNZ SEND1
SEND0 BIC.B #DIN,&P1OUT
JMP GOON
SEND1 BIS.B #DIN,&P1OUT
GOON BIS.B #CLK,&P1OUT
RLA R10
BIC.B #CLK,&P1OUT
DEC R6
JNZ SENDLOOP
RET
END
評(píng)論
查看更多