I ran into an unexpected issue with the MSP430fr5969 . Please bear with me if this is "common knowledge". I'm doing a very simple test program that just uses PWM to control LED brightness. I took the example source, modified it to suit my application and it didn't work. After perusing the original and the modified code side by side I finally spotted the difference. I had clock initialized before ports. And it wouldn't work. After I reverse clock init after ports, it works as expected. Why is that? init is called from main immediately after watchdog and LPM5 are switched off. void init(void){ //Set DCO frequency to 16 MHz CS_setDCOFreq(CS_DCORSEL_1,CS_DCOFSEL_4); //Set SMCLK = DCO with frequency divider of 32 = 500kHz CS_initClockSignal(CS_SMCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_32); //Set MCLK = DCO with frequency divider of 1 CS_initClockSignal(CS_MCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_1); //P1.4 as PWM output GPIO_setAsPeripheralModuleFunctionOutputPin( GPIO_PORT_P1, GPIO_PIN4, GPIO_PRIMARY_MODULE_FUNCTION ); //P2.6 as PWM output GPIO_setAsPeripheralModuleFunctionOutputPin( GPIO_PORT_P2, GPIO_PIN6, GPIO_PRIMARY_MODULE_FUNCTION );
↧