TIMER.rar

  • BOPER
    了解作者
  • Others
    开发工具
  • 2KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 3
    下载次数
  • 2012-01-05 22:37
    上传日期
时钟程序msp430的,希望对大家有用,快点啊
TIMER.rar
  • TIMER.txt
    4.5KB
内容介绍
/已经调试通过 南京航空航天大学 魏小龙 //LCD显示程序,使用于430实验板的电表液晶。可以直接下载到电路运行的 //走时钟程序 液晶与数码管同时显示 只有秒与分,(只是意思以一下,不准的哦)其他原理一样,希望网友自己编写。 //***************************************************************************** // MSP-FET430P440 Demo - LCD Put "6543210" on STK/EVK LCD // // Description; Put "6543210" on MSP-EVK430S320 LCD. // ACLK = LFXT1 = 32768, MCLK = SMCLK = DCO = 32xACLK = 1.048576MHz // //*An external watch crystal is required on XIN/XOUT for ACLK*// // // MSP430F449 // ----------------- // /|\| XIN|- // | | | 32kHz // --|RST XOUT|- // | | // +-|R33 P5.1| ----------------- // 1m | - |--> | + 7 6 5 4 3 2 1 | // +-|R23 P3.2| ----------------- // 1m | COM0|-----|||| // +-|R13 COM1|------||| // 1m | COM2|-------|| // +-|R03 COM3|--------| // | | | // Vss // // M.Buccini // Texas Instruments, Inc // January 2002 // Built with IAR Embedded Workbench Version: 1.25A //***************************************************************************** #include <msp430x44x.h> #define uchar unsigned char #define uint unsigned int uchar key_buffer; uchar key_long; unsigned char disbuffer[8]={0,1,3,8,0xf,5,0x18,7}; char digit[20] = {1,0,0,0,0,2,1,8 }; char distab[]={ 0xaf,0x06,0x6d,0x4f, 0xc6,0xcb,0xeb,0x0e, 0xef,0xcf, 0x77,0x7c, 0x39,0x5e,0x79,0x71 }; unsigned char seg[]={0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71, 0xbf,0x86,0xdb,0xcf, 0xe6,0xed,0xfd,0x87, 0xff,0xef,0xf7,0xfc, 0xb9,0xde,0xf9,0xf1, 0x80,0x40,0x00,0x73,0xc0}; void delay(int v) { while(v!=0)v--; } void main(void) { int i; WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer FLL_CTL0 |= XCAP14PF; // Configure load caps // LCDCTL = LCDON + LCD4MUX + LCDP2; // STK LCD 4Mux, S0-S17 LCDCTL = 0XFD; BTCTL = BTFRFQ1; // STK LCD freq P5SEL = 0xFC; // Common and Rxx all selected for(i=0;i<20;i++) LCDMEM[i]=0; for (i=1; i<9; ++i) // Display "6543210" LCDMEM[i] = distab[digit[i-1]];//digit[i]; P1DIR=0x1f; P1DIR=0X0f; P1OUT=0X0f; P1IE=0Xf0; P1IES=0; P1IFG=0; TACTL = TASSEL1 + TACLR; // SMCLK, clear TAR CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = 20000; TACTL |= MC1; // Start Timer_A in continuous mode P4DIR = 0XFF; _EINT(); // Enable interrupts for (;;) { _BIS_SR(CPUOFF); // CPU off _NOP(); // Required only for C-spy } } interrupt[TIMERA0_VECTOR] void Timer_A (void) { char i=0; for(i=0;i<7;i++) disbuffer[8-i]=digit[i]; CCR0 += 20000; // Add Offset to CCR0 for(i=1;i<7;i++) LCDMEM[i-1]=distab[digit[i]]; digit[0]++; LCDMEM[7]=0xa; LCDMEM[8]=0x90; LCDMEM[9]=0x12; LCDMEM[10]=0x80; LCDMEM[11]=0x2; LCDMEM[12]=0x93; LCDMEM[13]=0x72; LCDMEM[14]=0x5b; LCDMEM[15]=0x94; if(digit[0]==50) { digit[0]=0; digit[1]++; P4OUT = ~P4OUT; if(digit[1]==10) { digit[1]=0; digit[2]++; if(digit[2]==6) { digit[2]=0; digit[3]++; if(digit[3]==10) { digit[3]=0; digit[4]++; if(digit[4]==6) { digit[4]=0; } } } } } }
评论
    相关推荐