msp430+数码管显示程序
#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实现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 ;设置工作模式
BIC.B #LOAD,&P1OUT
CALL #MOVE
BIS.B #LOAD,&P1OUT
PUSH #00B05H ;设置扫描位数
BIC.B #LOAD,&P1OUT
CALL #MOVE
BIS.B #LOAD,&P1OUT
PUSH #009FFH ;设置编码方式
BIC.B #LOAD,&P1OUT
CALL MOVE
BIS.B #LOAD,&P1OUT
PUSH #00A07H ;设置亮度
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 ;设置工作模式
BIC.B #LOAD,&P1OUT
CALL #MOVE
BIS.B #LOAD,&P1OUT
PUSH #00B05H ;设置扫描位数
BIC.B #LOAD,&P1OUT
CALL #MOVE
BIS.B #LOAD,&P1OUT
PUSH #009FFH ;设置编码方式
BIC.B #LOAD,&P1OUT
CALL MOVE
BIS.B #LOAD,&P1OUT
PUSH #00A07H ;设置亮度
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
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)