Lab 4a – Program the MSP430 Clocks
5. Update myclocks.c – adding answers from the worksheet
Fill in the blanks with code you wrote on the worksheet.
//***** Header Files ************************************************
//#include <stdbool.h>
#include <driverlib.h>
#include "myClocks.h"
//***** Defines *****************************************************
#define LF_CRYSTAL_FREQUENCY_IN_HZ _______
#define HF_CRYSTAL_FREQUENCY_IN_HZ _______
#define MCLK_DESIRED_FREQUENCY_IN_KHZ _______
#define MCLK_FLLREF_RATIO ______/(UCS_REFOCLK_FREQUENCY/1024)
//***** Global Variables ********************************************
uint32_t myACLK = 0;
uint32_t mySMCLK = 0;
uint32_t myMCLK = 0;
//***** Functions ***************************************************
void initClocks(void) {
// Initialize the XT1 and XT2 crystal frequencies being used
// so driverlib knows how fast they are
_______________________
_______________________
_______________________
// Verify if the default clock settings are as expected
myACLK = UCS_getACLK( UCS_BASE );
mySMCLK = UCS_getSMCLK( UCS_BASE );
myMCLK = UCS_getMCLK( UCS_BASE );
// Setup ACLK to use REFO as its oscillator source
UCS_clockSignalInit( UCS_BASE,
UCS_ACLK, // Clock you're configuring
___________________, // Clock source
UCS_CLOCK_DIVIDER_1 // Divide down clock source
);
// Set the FLL's clock reference clock source
UCS_clockSignalInit( UCS_BASE,
UCS_FLLREF, // Clock you're configuring
___________________, // Clock source
UCS_CLOCK_DIVIDER_1 // Divide down clock source
);
// Configure the FLL's frequency and set MCLK & SMCLK to use the FLL
UCS_initFLLSettle( UCS_BASE,
MCLK_DESIRED_FREQUENCY_IN_KHZ, // MCLK frequency
___________________ // Ratio between MCLK and
// FLL's ref clock source
);
// Verify that the modified clock settings are as expected
myACLK = UCS_getACLK( UCS_BASE );
mySMCLK = UCS_getSMCLK( UCS_BASE );
myMCLK = UCS_getMCLK( UCS_BASE );
}
Worksheet
Question #6
Worksheet
Question #11
Worksheet
Question #7
Worksheet
Question #8
Worksheet
Question #10
Worksheet
Question #11/12
4 - 48 MSP430 Workshop - MSP430 Clocks & Initialization