Nguyễn Quốc Việt
Trứng gà
#include <msp430.h>
int x = 100;
void main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
// Port_init();
P2DIR |= (BIT1+BIT2);
P2OUT |= (BIT1+BIT2);
P2SEL |= (BIT1+BIT2);
TA1CTL = TASSEL_2 + MC_1 + TAIE; // SMCLK(1Mhz) // up mode //
TA1CCR0 =3000; //
TA1CCR1 = x; //modul timer
TA1CCTL1 =CCIE ;
TA1CCTL1 = OUTMOD_3; // ch?nh mode cho PWM
_BIS_SR(GIE); //
while(1)
{
;
}
}
#pragma vector=TIMER1_A1_VECTOR
__interrupt void INTERRUPT_ISR(void)
{
switch(TA1IV)
{
case 0x0A:
{
x += 100;
if(x == 3100)
{x = 0;}
break;
}
}
}
int x = 100;
void main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
// Port_init();
P2DIR |= (BIT1+BIT2);
P2OUT |= (BIT1+BIT2);
P2SEL |= (BIT1+BIT2);
TA1CTL = TASSEL_2 + MC_1 + TAIE; // SMCLK(1Mhz) // up mode //
TA1CCR0 =3000; //
TA1CCR1 = x; //modul timer
TA1CCTL1 =CCIE ;
TA1CCTL1 = OUTMOD_3; // ch?nh mode cho PWM
_BIS_SR(GIE); //
while(1)
{
;
}
}
#pragma vector=TIMER1_A1_VECTOR
__interrupt void INTERRUPT_ISR(void)
{
switch(TA1IV)
{
case 0x0A:
{
x += 100;
if(x == 3100)
{x = 0;}
break;
}
}
}