You are on page 1of 2

//T1,T2,T3,T4 ket noi tuong ung P1.4->P1.7 tich cuc muc 1 //a,b,c,d,e,f,g,h ket noi tuong ung P2.0->P2.

7 tich cuc muc 0 // 0 : P2 : hgfe dcba => 1100 0000 => 0xC0 //1 : #include<msp430g2452.h> #define T1 BIT4 #define T2 BIT5 #define T3 BIT6 #define T4 BIT7 int so[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; int phut=29,giay=30,cnt=0; void hienthiled(int number,int led) { P2OUT |=so[number];//hien thi so number P1OUT =led;//bat led 7 doan __delay_cycles(1000); P1OUT &=~led;//tat led 7 doan } void main(void) { WDTCTL=WDTHOLD +WDTPW;//Stop watchdog P2SEL =0; // Cau hinh cho P2 la GPIO P2DIR = 0xFF; // Cau hinh P2.0->P2.7 la output P1DIR=0xFf;//P1.4 ->P1.7 la output /* //cau hinh bo dem timer CCR0 - Tisr = 10ms TACCR0<65535 TACTL = TASSEL_2 + MC_1 ; // Cau hinh bo timer A CCR0 f=1,15Mhz, Prescaler=1 , Tisr=10ms TACCR0 = 11500-1; //gia tri dem TACCTL0 = CCIE; //Bat ngat timer _enable_interrupt();//Bat bit GIE - ngat toan cuc //_BIS_SR(GIE);//Bat ngat toan cuc */ while(1) { hienthiled(9,T1);//chuc phut hienthiled(8,T2);//chuc phut }

#pragma vector=TIMER0_A0_VECTOR __interrupt void TMR() { if(++cnt==100) { //500ms if(++giay<59) { if(++phut<59) phut=0; } }

You might also like