Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

Is this 38KHz PWM ?

$
0
0

Unfortunately I have no osciloscope , is this PWM OK to use it for an IR-Signal?


#include <msp430g2553.h>

void main(void) {

   int counter = 26; // Is this correct?

  WDTCTL = WDTPW + WDTHOLD;        // Stop watchdog timer

  P1DIR |= BIT6;                   // Set P1.6 to output direction
  P1OUT &= ~BIT6;                 // Set the green LED off
  P1SEL |= BIT6;                  // Green LED controlled by PWM

  TA0CCR0 = counter;                // Count limit (16 bit)
  TA0CCR1 = counter/2;              // 50% duty cycle
  TA0CCTL0 = 0x10;                 // Enable Timer A0 interrupts, bit 4=1
  TA0CCTL1 = OUTMOD_7;
TA0CTL = TASSEL_2 + MC_1;        // Timer A0 with ACLK, count UP



  _BIS_SR(LPM0_bits + GIE);        // LPM0 (low power mode) interrupts enabled

}

#pragma vector=TIMER1_A0_VECTOR    // Timer1 A0 interrupt service routine

  __interrupt void Timer1_A0 (void) {

                    // NOOP
}


Viewing all articles
Browse latest Browse all 2077

Trending Articles