Tool/software:
I cannot change the PWM duty cycle and period on my MSP430FR2355 EVM kit. I've tried sample code, I've written my own code, and used code I found online, but I still cannot get it to work. Here is my latest code which outputs a 32.7kHz PWM signal on P1.1. However, changing the CCRO, CCR1, and CCR2 values don't change the period of frequncey, it's always 50% at 32.7kHz. Thame sample code in MSPware is for the MSP430FR243x and while I've adapted that to work in this case, I still cannot control the PWM.
Requirements:
Using SMCLK
Ultimately I want a 40kHz PWM so I will be setting CCRO=24 and CCR1=12
#include "intrinsics.h"
#include "msp430fr2355.h"
#include <driverlib.h>
#include <msp430.h>
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
// Configure P1.1 and P1.2 as Timer_B outputs
P1DIR |= BIT1 | BIT2; // P1.1 and P1.2 set as output
P1SEL1 |= BIT1 | BIT2; // P1.1 and P1.2 options select
// Disable GPIO high-impedance mode
PM5CTL0 &= ~LOCKLPM5;
TB0CCR0 = 1000 - 1; // PWM Period (e.g., 1 kHz with SMCLK at 1 MHz)
TB0CCTL1 = OUTMOD_7; // CCR1 reset/set
TB0CCR1 = 500; // CCR1 PWM duty cycle (50%)
TB0CCTL2 = OUTMOD_7; // CCR2 reset/set
TB0CCR2 = 250; // CCR2 PWM duty cycle (25%)
TB0CTL = TBSSEL__SMCLK | MC__UP | TBCLR; // SMCLK, up mode, clear TAR
__bis_SR_register(LPM0_bits); // Enter LPM0
__no_operation(); // For debugger
}
