This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430G2231 (LaunchPad) VLO clock - how to get actual frequency?

Other Parts Discussed in Thread: MSP430G2553

Dear Sirs,

I'm trying to start with VLO as a source for MCLK. I wrote the code for LaunchPad:

#include "io430.h"


int main( void )

{
 // Stop watchdog timer to prevent time out reset

WDTCTL = WDTPW + WDTHOLD;

P1DIR = 0x40; // P1.6 output (green LED)
P1OUT = 0; // LED off

BCSCTL3 |= LFXT1S_2; // LFXT1 = VLO
IFG1 &= ~OFIFG; // Clear OSCFault flag
__bis_SR_register(SCG1 + SCG0); // Stop DCO
BCSCTL2 |= SELM_3 + DIVM_0; // MCLK = VLO

asm("bic.b #040h,&P1OUT");
asm("bis.b #040h,&P1OUT"); 
asm("bic.b #040h,&P1OUT");
asm("bis.b #040h,&P1OUT");
asm("bic.b #040h,&P1OUT");
asm("bis.b #040h,&P1OUT");
asm("bic.b #040h,&P1OUT");
asm("bis.b #040h,&P1OUT");

 return 0;

} 

The series of asm directives is used to produce 4 square waveforms on P1.6 (LED is connected there in LaunchPad).

As each instruction's execution lasts (as I hope :) ) 1 cycle = 1/F_MCLK = 1/F_VLO, period of waveform on P1.6 will be 2*cycle. [UPDATED: It looks to be wrong. MOV command for immediate addressed source and absolute addressed destination should use 5-1=4 cycles, according to p.150 of slau144i.pdf : MOV #N,&EDE , see note 1. Nevertheless, please explain me the correct way of measuring VLO frequency] For a typical value of VLO frequency near 12kHz, it should be around 6kHz waveform.

But my oscilloscope shows 4 periods 906uS length each. Also my frequency meter shows me around 1kHz.

So it looks like my VLO operates at frequency about 2kHz.&nbsp%

  • Hi,

    you can measure the clock more or less directly on many devices. For example MSP430G2553 has the pin 1.4 configurable as SMCLK output.

  • Ilia Davidov said:
    As each instruction's execution lasts (as I hope :) ) 1 cycle

    From reading the MSP430x2xx Family User's Guide SLAU144I the bic.b and bis.b instructions used are Format-I (Double Operand) Instructions with a source addressing mode of Immediate mode (#N) and destination addressing mode of Absolute mode (#ADDR) will take 5 cycles to execute.

    Given that the VLO is specified with Min frequency 4KHz, Typical 12KHz and Max 20KHz this could explain your measurement.

    On the subject of measuring the VLO frequency:

    1) VLOCLK can be selected as the source for ACLK

    2) ACLK can be output on a when it can be measured externally (pin may vary according to device)

  • Thanks a lot for your answers. Now I understood how it works.

    Regards,

    Ilia V. Davidov 

  • Chester Gillon said:
    From reading the MSP430x2xx Family User's Guide SLAU144I the bic.b and bis.b instructions used are Format-I (Double Operand) Instructions with a source addressing mode of Immediate mode (#N) and destination addressing mode of Absolute mode (#ADDR) will take 5 cycles to execute.

    Right. However, if it weren't bit 6 but rather bit 0..3 that is toggled, the assembler would generate an instruction using the constant generator, which does not have an explicit immediate parameter and takes one cycle less.
    AFAIK, there is no way to tell the assembler it shall use immediate mode and therefore the longer/slower variant (for deterministic code independent of the bit used). Except of directly providing the binary value of the instruction.

**Attention** This is a public forum