1273 views|0 replies

1667

Posts

0

Resources
The OP
 

MSP430 Clock Analysis [Copy link]

I recently started to learn MSP430. Among all the single-chip microcomputers, clock setting is undoubtedly the most basic task! Especially for the current single-chip microcomputers, there are two types of crystal oscillators, low-speed and high-speed, and internal clock sources of PLL. Setting the clock of the system is the perfect start of the work.

A total of two series of 430 microcontrollers are used, MSP430F149 and MSP430F437. The clock settings are slightly different for different series. Let's talk about the clock of 149 step by step!

In f149, the basic clock is called basic clock module.

There are three clock sources:

A LFXT1CLK is a low-speed/high-speed crystal source, usually connected to 32.768khz, and can also be connected to (400khz~8Mhz)

One is XT2CLK, which is connected to a standard high-speed crystal oscillator, usually 8Mhz, but can also be connected to (400khz~8Mhz)

There is also one called DCOCLK, which is an internal crystal oscillator consisting of an RC oscillation circuit.

There are three clock systems in 430

One is ACLK, which is usually based on LFXT1CLK as the clock source. The clock division system can be controlled by software.

One is MCLK, i.e. Main CLK. It is the main clock unit, providing clock for the system core. It can be selected from three clock sources by software.

One is SMCLK, called auxiliary master clock, which can also be selected by software.

Basic Clock Module Registers

DCO control register DCOCTL

Basic clock system control 1 BCSCTL1

Basic clock system control 2 BCSCTL2

SFR interrupt enable register 1 IE1

SFR interrupt flag register 1 IFG1

The DCOCTL register is used to configure DCOCLK, which will not be mentioned here.

The BCSCTL1 and BCSCTL2 registers are more important. These two registers control the 430 working clock system in your entire system.

BCSCTL1 Register:

7 6 5 4 3 210

XT2OFF XTS DIVAx XT5V RSELx

XT20FF: Used to control the opening and closing of the XT2 crystal oscillator. When set to 1, it is closed, and when set to 0, it is opened.

XTS: Used to select the working mode of low-speed crystal (can be ignored)

DIVAx: Used to select the division factor of ACLK

XT5V: useless

RSELx: Select resistor (not used, usually set to 0)

BCSCTL2

7 6 5 4 3 2 1 0

SELMx DIVMx SELS DIVSx DOCR

SELMx: Select the clock source of MCLK,

00 DCOCLK

01 DCOCLK

10 XT2CLK

11 LFX1CLK

DIVMx: MCLK frequency division

00 1 frequency division

01 2-way

10 4-way

11 8-way

SELS: SMCLK clock source, 0 is the built-in DCO, 1 is the external high-speed XT2

DIVSx: SMCLK frequency division, same as MCLK frequency division

DCOR: Is the resistor for controlling the frequency internal or external? (never used)

Instance Initializer

void Init_CLK(void)

{
unsigned int i;

BCSCTL1=0x00; //XT2 is turned on, LFXTCLK is in low frequency mode, ACLK frequency division is 0

do
{
IFG1&=~OFIFG;

for(i=0x20;i>0;i--);

}

while((IFG1&OFIFG)==OFIFG); //When OSCFault=1, that is, the crystal oscillator does not oscillate, wait

BCSCTL2=0X00;

BCSCTL2|=SELM1; //MCLK clock is XT2,

BCSCTL2|=SELS; //SMCLK clock is XT2

}

This post is from Microcontroller MCU
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list