I am designing a simple motion sensor driven by the MSP430F5438. In order to make it work I need to drive a 40 kHz pwm signal into the sensor. I used example code to first learn how the PWM signal works. This is the code I used at first (watchdog timer disable excluded for brevity), which will drive a PWM signal out of pins 27 and 28, also denoted as P2.2/TA1.1 and P2.3/TA1.2. Using an oscilloscope I verified the correct output.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
P2DIR |= 0x0C; // P2.2 and P2.3 output
P2SEL |= 0x0C; // P2.2 and P2.3 options select
TA1CCR0 = 128; // PWM Period/2
TA1CCTL1 = 0x80;//OUTMOD_4; // CCR1 toggle
TA1CCR1 = 32; // CCR1 PWM duty cycle
TA1CCTL2 = OUTMOD_4; // CCR2 toggle
TA1CCR2 = 96;
TA1CTL = TASSEL_2 + MC_1 + TACLR; // SMCLK, up-down mode, clear TAR
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
My problem comes in that I need to use pin 22 to drive my output, which is also denoted P1.5/TA0.4. I understand how to change my pin selections and I believe I have changed the control registers correctly yet I still get nothing out of the pin. Below is the code I am using to try to drive it.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
P1DIR |= 0x20; // P1.5 Output
P1SEL |= 0x20; // P1.5 Option Selection
TA0CCR0 = 128; // PWM Period
TA0CCTL1= OUTMOD_4; // Toggle Output
TA0CCR1 = 384; // CCR1 PWM duty cycle
TA0CTL = TASSEL_2 + MC_3 + TACLR; // ACLK, up/down mode, clear TAR
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
If anyone understands what I'm doing wrong I'd appreciate any help given.