First off: I'm brand new to microcontroller development, so please forgive me for the simple question. I'm trying to learn for my FIRST robotics team so we can use the MSP430 to handle some extra sensors.
I'm working on understanding/configuring the Unified Clock System. I want it to run on the 39 MHz setting. I've been reading the family guide and device specific datasheet. I think I have a basic understanding. My code is below:
/* * Objective: have SMCLK run at 39 MHz for driving an SPI */ WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer __bis_SR_register(SCG0); //Disable FLL UCSCTL0 = DCO0+DCO1+DCO2+DCO3+DCO4 ; //DCO 31 bit and MOD bit 0 [THIS IS NOT WORKING] UCSCTL1 = DCORSEL_6; //Select frequency range on www.ti.com/.../msp430f5529.pdf page 31 UCSCTL2 = 0x000; //Select no loop divider UCSCTL3 |= SELREF_2; //Set FLL reference to REFOCLK (only internal) UCSCTL4 |= SELS__DCOCLK; //Select SMCLK clock source to be DCOCLK P1DIR |= (BIT0 + BIT2); //irrelevant P2DIR |= BIT2; //Set P2.2 as out direction to monitor clock P2SEL |= BIT2; //Select P2.2 as SMCLK output defined in www.ti.com/.../msp430f5529.pdf pg 84 __bic_SR_register(SCG0); //Enable FLL
However, this dosen't work as my oscilloscope gets no reading from P2.2. When I change UCSCTL0 to 0x000 its works but is only going at ~7.x MHz. When looking at the register value through the debugger, all the USCSTLx registers are correct EXCEPT for USCSTL0. Which I believe may not be working how I think. Could someone please explain how UCSTL0 is configured and what I need to do in order to have it run at 39 MHz?