1877 views|0 replies

3836

Posts

19

Resources
The OP
 

MSP430G2553 clock external crystal configuration instructions [Copy link]

The following will not explain the clock classification of MSP430G2553 and the clock sources of ACLK, MCLK and SMCLK in detail. You can find many related articles on Baidu or CSDN. This article mainly demonstrates the frequency of LFXT1CLK, which can be selected as the clock source of ACLK, MCLK and SMCLK. The passive crystal oscillator in the circuit board shown below cannot be found in BAIDU and TAOBAO, so I want to deduce it myself. (The crystal oscillator in the technical document of 2553 is a 32kHz crystal oscillator)

Main ideas:

Configure the relevant clock registers, use the external crystal oscillator LFXT1CLK as the clock source of SMCLK, and use SMCLK as the clock source of timer A. Configure the timer to make the corresponding pin output PWM wave. According to the frequency of the PWM wave, the frequency of the external passive crystal oscillator corresponding to LFXT1CLK is finally derived.

This step
mainly uses the system default clock configuration. The timer A module outputs PWM wave with MCLK as the clock source. The frequency of MCLK is reversely deduced according to the PWM period. According to the user manual, under the default clock condition, the clock source of MCLK is DCOCLK, and the frequency is 1.1MHz.

The following is the register configuration of Timer A:

void PWM_Init(void)
{
unsigned const PWMPeriod = 800; //const limits a variable to not be changed

P1DIR |= BIT6; // Set P1.6 to output
P1SEL |= BIT6; // Set P1.6 to TA0.1 output

CCR0 = PWMPeriod; // Set PWM period
CCTL1 = OUTMOD_7; // Set PWM output mode to: 7 - PWM reset/set mode,
// That is, the output level is reset when the value of TAR is equal to CCRx, and is set when the value of TAR is equal to CCR0.
TACTL = TASSEL_2 + MC_1; // Set the clock source of TIMERA to SMCLK, and the counting mode to up
}


void PWM_SetDuty(unsigned int duty)
{
CCR1 = duty;
}
unsigned int Timer_A_duty = 200;

void main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;

PWM_Init(); //PWM initialization
PWM_SetDuty(Timer_A_duty); //

while(1)
{

}

The
waveform of the P1^6 pin measured by a logic analyzer is as follows:

It can be seen that the period is 0.7899ms, that is, the time taken by the timer to count 800 times. Then, the clock source frequency of the timer at this time, that is, the frequency of SMCLK, is 1/(0.7899ms/800) = 1.012MHz, which meets the requirement of fluctuating around 1.1MHz. Therefore, it is feasible to use this method to verify the frequency of the external crystal oscillator.

This post is from Microcontroller MCU
 

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

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