|
- // GND 电源地
- // VCC 接5V或3.3v电源
- // D0 P33(时钟)
- // D1 P34(数据)
- // RES 接P35
- // DC 接P32
- // CS 接P36
- #include <io430.h>
- #include "oled.h"
- char e=34,s=27,i=16;
- int a=0;
- int j;
- int ii;
- void main( void )
- {
- WDTCTL = WDTPW + WDTHOLD;
-
- P2REN |= BIT1;
- P2OUT |= BIT1;
- P2IES |= BIT1;
- P2IFG &= ~BIT1; //打开中断
- P2IE |= BIT1;
-
- OLED_Init(); //初始化OLED
- OLED_Clear();
-
- TA0CCTL0 = CCIE;
- TA0CCR0 = 2500;
-
- OLED_ShowCHinese(0,0,0);
- OLED_ShowCHinese(18,0,1);
- OLED_ShowCHinese(36,0,2);
- OLED_ShowCHinese(54,0,3);
- OLED_ShowCHinese(72,0,4);
- OLED_ShowCHinese(90,0,5);
- OLED_ShowCHinese(108,0,6);
- OLED_ShowChar(30,4,16);
- OLED_ShowChar(40,4,e);
- OLED_ShowChar(50,4,38);//时间:
- OLED_ShowChar(60,4,s);
- OLED_ShowChar(70,4,i);
- // TA0CTL|=TASSEL_1+MC_2+TACLR;//时钟源
- //TA0CTL=TASSEL_1+TACLR+MC_1;
- TA0CTL=TASSEL_1+TACLR+MC_3;
- //TACLR 为定时器清除位
- //MC_3处于增减计数模式下
- //TASSEL_1时钟源选择为辅助时钟
- __enable_interrupt();
-
- while(1)
- {
- if(a%2==1)
- {
- TA0CCR0 = 2500; //增计数模式,ccr0计数到0时P1IF置位。
- //TA0CTL=TASSEL_1+TACLR+MC_3;
- TA0CCTL0 = CCIE; //允许中断
- }
- if(a%2==0)
- {
- // TA0CTL=MC_0;
- TA0CCTL0 = ~CCIE; //禁止中断
- }
- }
- }
- #pragma vector=TIMER0_A0_VECTOR
- __interrupt void TIMER0_A0_ISR(void)
- {
- ii++;
- //if(ii==12)
- if(ii==7)
- {
- OLED_ShowChar(30,4,16);
- OLED_ShowChar(40,4,e);
- OLED_ShowChar(50,4,38);
- OLED_ShowChar(60,4,s);
- OLED_ShowChar(70,4,i);
- i++;
-
- if(i==26)
- {
- i=16;
- s++;
- }
- if(s==33)
- {
- s=27;
- e++;
- }
- if(e==37)
- {
- e=34;
- }
- ii=0;
- }
- }
- #pragma vector=PORT2_VECTOR
- __interrupt void Port_2(void) //按键按下
- {
- int x;
- for(x=0;x<25000;x++);//延时消抖
- if((P2IN&0xff)!=0xff)
- {
- a++;
- }
- P2IFG &= ~BIT1;//标志位清零
- }
- /*
- #pragma vector=PORT1_VECTOR
- __interrupt void Port_1(void)
- {
- int j;
- for(j=0;j<25000;j++);//延时消抖
- if((P1IN&0xff)!=0xff)
- {
- e=34;
- s=27;
- i=16;
- }
- P1IFG &= ~BIT1;//标志位清零
- }*/
复制代码
|
|