EasyManuals Logo

Texas Instruments MSP430 Student Guide

Texas Instruments MSP430
398 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #393 background imageLoading...
Page #393 background image
Appendix – Looking ‘Under the Hood’
Gettings Started with the MSP430 - Using Energia (Arduino) 8 - 35
Sidebar – initClocks()
Here is a snippet of the initClocks() function found in wiring.c (for the ‘G2553 Launchpad). We
call it a snippet, since we cut out the other CPU speeds that are also available (8 & 12 MHz).
The beginning of this function starts out by setting the calibration constants (that are provided in
Flash memory) to their associated clock configuration registers.
(Sidebar): initClocks() in wiring.c
void initClocks(void)
{
#if (F_CPU >= 16000000L)
BCSCTL1 = CALBC1_16MHZ;
DCOCTL = CALDCO_16MHZ;
#elif (F_CPU >= 1000000L)
BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;
#endif
BCSCTL2 &= ~(DIVS_0);
BCSCTL3 |= LFXT1S_2;
CSCTL2 &= ~SELM_7;
CSCTL2 |= SELM__DCOCLK;
CSCTL3 &= ~(DIVM_3|DIVS_3);
#if F_CPU >= 16000000L
CSCTL1 = DCORSEL;
#elif F_CPU >= 1000000L
CSCTL1 = DCOFSEL0|DCOFSEL1;
CSCTL3 |= DIVM_3;
#endif
}
Select correct calibration
constants based on chosen clock
frequency
F_CPU defined in boards.txt
Select ‘board’ via: ToolsBoards
Set MCLK as per F_CPU
Set SMCLK to F_CPU
Set ACLK to VLO (12Khz)
Clear main clock (MCLK)
Use DCO for MCLK
Clear divide clock bits
If you work your way through the second and third parts of the code, you can see the BCS (Basic
Clock System) control registers being set to configure the clock sources and speeds. Once again,
there are more details on this in Clocking chapter and its lab exercise.

Table of Contents

Other manuals for Texas Instruments MSP430

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments MSP430 and is the answer not in the manual?

Texas Instruments MSP430 Specifications

General IconGeneral
BrandTexas Instruments
ModelMSP430
CategoryMicrocontrollers
LanguageEnglish

Related product manuals