Has anyone experienced any issues with PWM using the MSP430FR2xx series devices?
I tried the driverlib sample codes for the MSP430FR2311 launchpad and a custom MSP430FR2433, but am having no luck. The code runs fine, but it simply doesn't generate the output on the PWM channel (using P2_0) I am using the following code for the MSP430FR2311 launchpad:
#include "driverlib.h"
#define CS_MCLK_DESIRED_FREQUENCY_IN_KHZ 12000
#define CS_MCLK_FLLREF_RATIO 366
uint32_t clockValue = 0;
uint16_t status;
void initClock();
void checkClock();
void main(void)
{
//Stop WDT
WDT_A_hold(WDT_A_BASE);
//Set P1.2 to output direction
GPIO_setAsOutputPin(GPIO_PORT_P1,GPIO_PIN2);
GPIO_setAsOutputPin(GPIO_PORT_P2,GPIO_PIN0);
GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P2,GPIO_PIN0,GPIO_PRIMARY_MODULE_FUNCTION);
PMM_unlockLPM5();
initClock();
// Enable global interrupt
__bis_SR_register(GIE);
checkClock();
Timer_B_outputPWMParam param = {0};
param.clockSource = TIMER_B_CLOCKSOURCE_SMCLK;
param.clockSourceDivider = TIMER_B_CLOCKSOURCE_DIVIDER_1;
param.timerPeriod = 600;
param.compareRegister = TIMER_B_CAPTURECOMPARE_REGISTER_1;
param.compareOutputMode = TIMER_B_OUTPUTMODE_RESET_SET;
param.dutyCycle = 200;
Timer_B_outputPWM(TIMER_B1_BASE, ¶m);
while(1);
}
void initClock(){
//Set DCO FLL reference = REFO
CS_initClockSignal(CS_FLLREF,CS_REFOCLK_SELECT,CS_CLOCK_DIVIDER_1);
//Set ACLK = REFO
CS_initClockSignal(CS_ACLK,CS_REFOCLK_SELECT,CS_CLOCK_DIVIDER_1);
//Set Ratio and Desired MCLK Frequency and initialize DCO
CS_initFLLSettle(CS_MCLK_DESIRED_FREQUENCY_IN_KHZ,CS_MCLK_FLLREF_RATIO);
//Clear all OSC fault flag
CS_clearAllOscFlagsWithTimeout(1000);
//Enable oscillator fault interrupt
SFR_enableInterrupt(SFR_OSCILLATOR_FAULT_INTERRUPT);
}
void checkClock(){
//Verify if the Clock settings are as expected
clockValue = CS_getSMCLK();
clockValue = CS_getMCLK();
clockValue = CS_getACLK();
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=UNMI_VECTOR
#elif defined(__GNUC__)
__attribute__((interrupt(UNMI_VECTOR)))
#endif
void NMI_ISR(void)
{
do
{
// If it still can't clear the oscillator fault flags after the timeout,
// trap and wait here.
status = CS_clearAllOscFlagsWithTimeout(1000);
}
while(status != 0);
}