Flipklok
 
Loading...
Searching...
No Matches
clock.h File Reference
#include <msp430.h>

Go to the source code of this file.

Functions

void setupClocks ()
 Setup clocks of system, all to LFXTAL input, get called from main()
 

Function Documentation

◆ setupClocks()

void setupClocks ( )

Setup clocks of system, all to LFXTAL input, get called from main()

Definition at line 16 of file clock.c.

17{
18 BCSCTL1 |= XT2OFF; // Disable XT2
19 BCSCTL1 &= ~XTS; //LFXT1
20 BCSCTL1 |= DIVA_0; // ACLK Divider 0: /1
21
22// BCSCTL2 |= SELM_3; // LFXT1CLK,
23// BCSCTL2 |= DIVM_0; // MCLK Divider 0: /1, LFXT1CLK, SMCLK Divider 0: /1
24 BCSCTL2 |= SELS; // LFXT1CLK, SMCLK Divider 0: /1
25 BCSCTL2 |= DIVS_0; // SMCLK Divider 0: /1
26 BCSCTL3 |= LFXT1S_0; // Mode 0 for LFXT1
27 BCSCTL3 |= XCAP_2; // Approximately 10 pF
28
29 //Enable when running cpu on 1 MHz instead of LFXTAL
30 BCSCTL1 |= CALBC1_1MHZ; // Load calibrated DCO setting for 1 MHz
31 DCOCTL |= CALDCO_1MHZ; // Load fine-tuned DCO setting
32 BCSCTL2 |= SELM_0; // MCLK = DCO
33 BCSCTL2 |= DIVM_0; // No division
34
35
36 // 3. Wait for the crystal to stabilize
37 while (IFG1 & OFIFG) { // Check oscillator fault flag
38 IFG1 &= ~OFIFG; // Clear oscillator fault flag
39 __delay_cycles(1000); // Wait for the crystal to stabilize
40 }
41}

Referenced by main().