#include <msp430.h>
#include"stdint.h"
uint8_t j=0;
//COM端口设置为 1-4对应6.0-6.3
uint8_t const P6DIR_COM[]={0X01,0X02,0X04,0X08,0X01,0X02,0X04,0X08};
uint8_t const P6REN_COM[]={0X0E,0X0D,0X0B,0X07,0X0E,0X0D,0X0B,0X07};
uint8_t const P6OUT_COM[]={0X01,0X02,0X04,0X08,0X0E,0X0D,0X0B,0X07};
//SEG端口5-8对应I/O口3.0;3.1.2;3.2;3.4全灭状态
uint8_t const P2DIR_SEG1[]={0X00,0X00,0x00,0X00,0X00,0X00,0X00,0X00};
uint8_t const P2REN_SEG1[]={0X0F,0X0F,0X0F,0X0F,0X0F,0X0F,0X0F,0X0F};
uint8_t const P2OUT_SEG1[]={0X0F,0X0F,0X0F,0X0F,0X00,0X00,0X00,0X00};
//SEG端口5-8对应I/O口3.0;3.1.2;3.2;3.4在灭的基础下亮的状态
uint8_t const P2DIR_SEG_1[]={0X0f,0X00,0x00,0X00,0X0f,0X00,0X00,0X00};
uint8_t const P2REN_SEG_1[]={0X00,0X0F,0X0F,0X0F,0X00,0X0F,0X0F,0X0F};
uint8_t const P2OUT_SEG_1[]={0X0F,0X0F,0X0F,0X0F,0X00,0X00,0X00,0X00};
void chushi()
{ uint8_t i; for(i=0;i<8;i++) {
P3DIR=P2DIR_SEG1[i];//seg端口灭的状态
P3REN=P2REN_SEG1[i];
P3OUT=P2OUT_SEG1[i]; } }
void lcd_shuju() {
P3DIR=P2DIR_SEG_1[j];//seg端口亮的状态
P3REN=P2REN_SEG_1[j];
P3OUT=P2OUT_SEG_1[j];
}
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
TA0CCR0=250;//设置计数为2.5ms
TA0CTL=TACLR; TA0CTL=TASSEL_2+MC_1;
//+TACLR;//设置SMACK UPMODE CLEAR TAR
TA0CCTL0=CCIE; //开定时器0使能中断
__enable_interrupt(); //开总中断
lcd_com();chushi();
while(1);
// {
// } }
#pragma vector=TIMER0_A0_VECTOR
__interrupt void TIMER_A0(void)
{ lcd_shuju();
j++;
if(j==8) j=0;
TA0CCR0=250;//设置计数为2.5ms
}
灰小子:
用的哪个msp430?硬件是如何连接的?