1. Platform Description MS430F5438
// Clock defaults
// FLL clock FLL select XT1
// Auxiliary clock ACLK selects XT1 32768Hz
// Main system clock MCLK selection DCOCLKDIV 1048576Hz
// Subsystem clock SMCLK selection DCOCLKDIV 1048576Hz
#include
void clock_config(void);
void select_xt1(void);
void dco_config(void);
int main(void)
{
clock_config(); // Initialize the clock
P4DIR |= BIT0; //P4.0 output
while(1)
{
P4OUT ^= BIT0;
__delay_cycles(1000000);
}
}
void clock_config(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog
select_xt1(); // Select XT1
dco_config(); // ACLK = XT1 = 32.768K
// MCLK = SMCLK = 8000K
}
void select_xt1(void)
{
// Start XT1
P7SEL |= 0x03; // P7.0 P7.1 peripheral function
UCSCTL6 &= ~(XT1OFF); // XT1 is turned on
UCSCTL6 |= XCAP_3; // Internal capacitor
do
{
UCSCTL7 &= ~XT1LFOFFG; // Clear XT1 error flag
}while (UCSCTL7&XT1LFOFFG); // Check XT1 error flag
}
void dco_config(void)
{
__bis_SR_register(SCG0); // Disable FLL function
UCSCTL0 = 0x0000; // Set lowest possible DCOx, MODx
UCSCTL1 = DCORSEL_5; // DCO maximum frequency is 16MHz
UCSCTL2 = FLLD_1 + 243; // Set DCO frequency to 8MHz
// MCLK = SMCLK= Fdcoclkdiv = (N+1)X(Ffllrefclk/n)
// N is the only value that needs to be calculated
// Ffllrefclk FLL reference clock, default is XT1
// n takes the default value, which is 1
// (243 + 1) * 32768 = 8MHz
__bic_SR_register(SCG0); // Enable FLL function
// Necessary delay
__delay_cycles(250000);
// Clear the error flag
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG);
// Clear all oscillator error flags
SFRIFG1 &= ~OFIFG; // Clear oscillator error
}while (SFRIFG1&OFIFG); // Wait for clear completion
}
Previous article:MSP430Ware use notes to initialize XT1
Next article:MSP430F5438 study notes initialization XT1
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- [Synopsys IP Resources] Automotive cybersecurity starts with chips and IP
- ARM MCU and ARM Core
- What to do about analog switch crosstalk?
- 24-pin composite video encoder IC model required
- BMS Rapid Prototyping Platform
- The most basic IO configuration of MSP430
- Several problems found by using ATE to test GD32F450 (GD32 engineers can answer them if they see any)
- In AD, if the circle on the surface of the circuit board is not painted with green paint, should a solid circle or a ring be drawn on the TOPSOLDER layer?
- AD19 installation package always reports errors
- Tektronix offers free trials for more than 100 advanced application functions!