After the microcontroller is powered on, if the clock system is not set, the default 800 kHz DCOCLK is used as the clock source of MCLK and SMCLK, and LFXTl is connected to a 32768 Hz crystal and works in low-frequency mode (XTS=O) as the clock source of ACLK. The instruction cycle of the CPU is determined by MCLK, so the default instruction cycle is 1/800 kHz="1".25μs. To get an instruction cycle of lμs, the DCO frequency needs to be adjusted, that is, MCLK=1 MHz, and only the following settings are required: BCSCTLl=XT20FF+RSEL2;
// Turn off the XT2 oscillator and set the DCO frequency to 1 MHz
DCOCTL=DCO2
// Make the single instruction cycle lμs
The relationship between the MSP430 clock cycle (oscillation cycle), machine cycle, and instruction cycle
General knowledge The clock cycle is also called the oscillation cycle: it is defined as the inverse of the clock pulse (the clock cycle is the inverse of the crystal oscillator directly used by the internal CPU, such as a 12M crystal oscillator, its clock cycle is 1/12us), and is the most basic and smallest time unit in the computer. In one clock cycle, the CPU only completes one most basic action. The clock pulse is the basic working pulse of the computer, which controls the working rhythm of the computer. The higher the clock frequency, the faster the working speed. Machine cycle: In a computer, the execution process of an instruction is often divided into several stages, and each stage completes a task. Each task is called a basic operation, and the time required to complete a basic operation is called a machine cycle. A machine cycle of the 8051 series microcontroller consists of 6 S cycles (state cycles). One S cycle = 2 clock cycles, so one machine cycle of the 8051 microcontroller = 6 state cycles = 12 clock cycles. Instruction cycle: The time required to execute an instruction is generally composed of several machine cycles. Different instructions require different machine cycles. Special knowledge: In 430, one clock cycle = the inverse of the MCLK crystal oscillator. If MCLK is 8M, then one clock cycle is 1/8us; one machine cycle = one clock cycle, that is, each action of 430 can complete a basic operation; one instruction cycle = 1 to 6 machine cycles, depending on the specific instruction. In addition: the instruction length is just a storage unit and has no necessary relationship with time. MSP430 can choose to use up to 3 oscillators depending on the model. We can choose the appropriate oscillation frequency according to our needs, and we can turn off the oscillator at any time when not needed to save power. These three oscillators are:
(1) DCO digital controlled RC oscillator. It is inside the chip and can be turned off when not in use. The oscillation frequency of DCO will be affected by the ambient temperature and the operating voltage of the MSP430, and the frequency generated by the same model of chip is also different. However, the adjustment function of DCO can improve its performance. Its adjustment is divided into the following three steps: a: Select BCSCTL1.RSELx to determine the nominal frequency of the clock; b: Select DCOCTL.DCOx to make a rough adjustment in sections based on the nominal frequency; c: Select the value of DCOCTL.MODx for fine adjustment.
(2) LFXT1 is connected to a low-frequency oscillator. Typically, it is connected to a 32768HZ clock oscillator. In this case, the oscillator does not need to be connected to a load capacitor. It can also be connected to a 450KHZ~8MHZ standard crystal oscillator. In this case, a load capacitor is required.
(3) XT2 is connected to a standard crystal oscillator of 450KHZ~8MHZ. At this time, a load capacitor needs to be connected, which can be turned off when not in use.
Low frequency oscillators are mainly used to reduce energy consumption, such as battery-powered systems, and high frequency oscillators are used to respond quickly to events or for the CPU to perform large amounts of calculations. Of course, the high-end 430 also has frequency-locked loop (FLL) and FLL+ modules, but you don't need to consider so many of them at the beginning.
MSP430 has three clock signals: MCLK system main clock; SMCLK system sub-clock; ACLK auxiliary clock.
(1) MCLK system master clock. In addition to the CPU operation, peripheral modules can also use this clock. MCLK can select any clock signal generated by an oscillator and divide it by 1, 2, 4, or 8 as its signal source.
(2) SMCLK system sub-clock. For use by peripheral modules. It can be divided by the registers of each module before use. SMCLK can select the clock signal generated by any oscillator and divide it by 1, 2, 4, or 8 as its signal source.
(3) ACLK auxiliary clock. For use by peripheral modules. It can be divided by the registers of each module before use. However, ACLK can only be divided by 1, 2, 4, or 8 by LFXT1 as a signal source.
After PUC reset, the signal sources of MCLK and SMCLK are DCO, and the default oscillation frequency of DCO is 800KHZ. The signal source of ACLK is LFXT1.
The MSP430 contains a crystal oscillator failure monitoring circuit that monitors the clock signals output by LFXT1 (working in high-frequency mode) and XT2. When the clock signal is lost for 50us, the monitoring circuit detects the oscillator failure. If the MCLK signal comes from LFXT1 or XT2, the MSP430 automatically switches the MCLK signal to DCO, which ensures that the program continues to run. However, the MSP430 does not monitor the LFXT1 working in low-frequency mode.
In order to realize the specific clock, the registers related to the clock can be set. In the low-end 430, there are three registers: DCOCTL, BCSCTL1 and BCSCTL2. For the high-end 430, several registers such as SCFI0, SCFQCTL, FLL_CTL0, FLL_CTL1 and BTCTL should be considered.
Previous article:RS485 interface circuit schematic
Next article:The meaning of Atmel microcontroller models
- Popular Resources
- Popular amplifiers
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
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- 【ST NUCLEO-H743ZI Review】(1) Must-have lights for first experience
- Understand the design of constant current source circuit module in one article
- About the problem of optocoupler screen connector
- TI dsp clock circuit selection principles
- 【LAUNCHXL-CC1350-4】- 3: Build the development environment
- [nRF52840 DK Review] +52840 NFC (Part 2)
- What domestic chips are needed to DIY a fast-charging chromium iron or an electric chromium iron that works as a laptop power supply?
- Bluetooth module communicates with mobile phone
- The compilation of the program sent by serial communication always fails
- Does the clearance below the crystal oscillator refer to the layer where the chip is located or all layers?