EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Disabling DCO

Started by Harish Kumar March 3, 2008
Hi

I would like to know if there is anyway of disabling DCO (for
saving power) without entering any of the predefined low power modes.
I do not want to switch off the CPU but only the DCO. I have sourced
the MCLK from VLOCLK and set SCG0 and SCG1 to 1. I have attached the
code below.

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT

P1DIR |= 0x81;
P1OUT = 0x00;

for(int i=0;i<3000;i++)
{
P1OUT ^= 0x81;
}
BCSCTL3 |= LFXT1S_2;
IFG1 &= ~OFIFG;
BCSCTL2 |= SELM_3;
_BIS_SR(SCG0 + SCG1); //written to disable DCO

for(int i=0;i<50;i++)
{
P1OUT ^= 0x81;
}
for(int i=0;i<100;i++)
{}
P1OUT ^= 0x81;

_BIC_SR(SCG0 + SCG1); //written to enable DCO
BCSCTL2 = 0x00;
BCSCTL3 = 0x04;
for(int i=0;i<300;i++)
{
P1OUT ^= 0x81;
}
}
I have observed from an oscilloscope that while the clock source is
getting changed the DCO is not getting disabled since the program sets
DCO again even when the _BIC_SR(SCG0 + SCG1); command is commented.
I have inserted a breakpoint to check if SCG bits are set after the
command is executed by observing the register values in IAR. The bits
are set correctly.

I would be glad if anyone could help me out with this problem.

Thanking you
Harish

Beginning Microcontrollers with the MSP430

Hello Harish,

I do not know whihc MSP you are using because I got only 2 reg for basic clocks. Anyways, can you also see if you are changing source of SMCLK too.

By default BCSCLT2 = 0x00;

which means SMCLK and MCLK are sourced from DCO and even if you change source for MCLK like you are doing in your code, the source for SMCLK remains same (DCO) and in that case you can not switch off DCO.

LPMs are nothing but macros defined forSCGx bits for your convienence.

I am using following function:

void switchOffDCO(void)
{

BCSCTL2 = 0xc8; //MCLK and SMCLK from LFTX1
__bis_SR_register(LPM1_bits); //DCO Off

}

I hope this will help.

ciao
Rahul

________________________________

From: m... [mailto:m...] On Behalf Of Harish Kumar
Sent: Dienstag, 4. Mz 2008 02:23
To: m...
Subject: [msp430] Disabling DCO

Hi

I would like to know if there is anyway of disabling DCO (for
saving power) without entering any of the predefined low power modes.
I do not want to switch off the CPU but only the DCO. I have sourced
the MCLK from VLOCLK and set SCG0 and SCG1 to 1. I have attached the
code below.

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT

P1DIR |= 0x81;
P1OUT = 0x00;

for(int i=0;i<3000;i++)
{
P1OUT ^= 0x81;
}
BCSCTL3 |= LFXT1S_2;
IFG1 &= ~OFIFG;
BCSCTL2 |= SELM_3;
_BIS_SR(SCG0 + SCG1); //written to disable DCO

for(int i=0;i<50;i++)
{
P1OUT ^= 0x81;
}
for(int i=0;i<100;i++)
{}
P1OUT ^= 0x81;

_BIC_SR(SCG0 + SCG1); //written to enable DCO
BCSCTL2 = 0x00;
BCSCTL3 = 0x04;
for(int i=0;i<300;i++)
{
P1OUT ^= 0x81;
}
}

I have observed from an oscilloscope that while the clock source is
getting changed the DCO is not getting disabled since the program sets
DCO again even when the _BIC_SR(SCG0 + SCG1); command is commented.
I have inserted a breakpoint to check if SCG bits are set after the
command is executed by observing the register values in IAR. The bits
are set correctly.

I would be glad if anyone could help me out with this problem.

Thanking you
Harish






--- In m..., "Harish Kumar" wrote:
>
> Hi
>
> I would like to know if there is anyway of disabling DCO (for
> saving power) without entering any of the predefined low power modes.
> I do not want to switch off the CPU but only the DCO. I have sourced
> the MCLK from VLOCLK and set SCG0 and SCG1 to 1. I have attached the
> code below.
>
> void main(void)
> {
> WDTCTL = WDTPW + WDTHOLD; // Stop WDT
>
> P1DIR |= 0x81;
> P1OUT = 0x00;
>
> for(int i=0;i<3000;i++)
> {
> P1OUT ^= 0x81;
> }
> BCSCTL3 |= LFXT1S_2;
> IFG1 &= ~OFIFG;
> BCSCTL2 |= SELM_3;
> _BIS_SR(SCG0 + SCG1); //written to disable DCO
>
> for(int i=0;i<50;i++)
> {
> P1OUT ^= 0x81;
> }
> for(int i=0;i<100;i++)
> {}
> P1OUT ^= 0x81;
>
> _BIC_SR(SCG0 + SCG1); //written to enable DCO
> BCSCTL2 = 0x00;
> BCSCTL3 = 0x04;
> for(int i=0;i<300;i++)
> {
> P1OUT ^= 0x81;
> }
> }
> I have observed from an oscilloscope that while the clock source is
> getting changed the DCO is not getting disabled since the program sets
> DCO again even when the _BIC_SR(SCG0 + SCG1); command is commented.
> I have inserted a breakpoint to check if SCG bits are set after the
> command is executed by observing the register values in IAR. The bits
> are set correctly.
>
> I would be glad if anyone could help me out with this problem.
>
> Thanking you
> Harish
>
A few questions and suggestions.

You are using one of the newer chips. Which one are you using? Did you
check the Errata?

How do you know that DCO was not stopped? Are you using a scope to
measure the toggle rate of P1.0 or P1.7? There depend on MCLK and
cannot tell you whether DCO is stopped or not.

I suggest that you add: P2SEL = 0;

I suggest that you use: BCSCTL3 = LFXT1S_2; instead of:BCSCTL3 |LFXT1S_2;

--- In m..., "Harish Kumar" wrote:
>
> Hi
>
> I would like to know if there is anyway of disabling DCO (for
> saving power) without entering any of the predefined low power modes.
> I do not want to switch off the CPU but only the DCO. I have sourced
> the MCLK from VLOCLK and set SCG0 and SCG1 to 1. I have attached the
> code below.
>
> void main(void)
> {
> WDTCTL = WDTPW + WDTHOLD; // Stop WDT
>
> P1DIR |= 0x81;
> P1OUT = 0x00;
>
> for(int i=0;i<3000;i++)
> {
> P1OUT ^= 0x81;
> }
> BCSCTL3 |= LFXT1S_2;
> IFG1 &= ~OFIFG;
> BCSCTL2 |= SELM_3;
> _BIS_SR(SCG0 + SCG1); //written to disable DCO
>
> for(int i=0;i<50;i++)
> {
> P1OUT ^= 0x81;
> }
> for(int i=0;i<100;i++)
> {}
> P1OUT ^= 0x81;
>
> _BIC_SR(SCG0 + SCG1); //written to enable DCO
> BCSCTL2 = 0x00;
> BCSCTL3 = 0x04;
> for(int i=0;i<300;i++)
> {
> P1OUT ^= 0x81;
> }
> }
> I have observed from an oscilloscope that while the clock source is
> getting changed the DCO is not getting disabled since the program sets
> DCO again even when the _BIC_SR(SCG0 + SCG1); command is commented.
> I have inserted a breakpoint to check if SCG bits are set after the
> command is executed by observing the register values in IAR. The bits
> are set correctly.
>
> I would be glad if anyone could help me out with this problem.
>
> Thanking you
> Harish
>
Hi

I am using MSP430F2013. I would like to know what happens when SCG1 and
SCG0 are set to 1 while CPUOFF is at 0. This case has not been mentioned in
the data sheets. I do not want to disable MCLK or the CPU. I am trying to
change the clock source from DCO to VLOCLK then disable DCO instead of
letting it idle.

Harish

On Tue, Mar 4, 2008 at 11:09 PM, old_cow_yellow
wrote:

> A few questions and suggestions.
>
> You are using one of the newer chips. Which one are you using? Did you
> check the Errata?
>
> How do you know that DCO was not stopped? Are you using a scope to
> measure the toggle rate of P1.0 or P1.7? There depend on MCLK and
> cannot tell you whether DCO is stopped or not.
>
> I suggest that you add: P2SEL = 0;
>
> I suggest that you use: BCSCTL3 = LFXT1S_2; instead of:BCSCTL3 |> LFXT1S_2;
> --- In m... , "Harish Kumar"
> wrote:
> >
> > Hi
> >
> > I would like to know if there is anyway of disabling DCO (for
> > saving power) without entering any of the predefined low power modes.
> > I do not want to switch off the CPU but only the DCO. I have sourced
> > the MCLK from VLOCLK and set SCG0 and SCG1 to 1. I have attached the
> > code below.
> >
> > void main(void)
> > {
> > WDTCTL = WDTPW + WDTHOLD; // Stop WDT
> >
> > P1DIR |= 0x81;
> > P1OUT = 0x00;
> >
> > for(int i=0;i<3000;i++)
> > {
> > P1OUT ^= 0x81;
> > }
> > BCSCTL3 |= LFXT1S_2;
> > IFG1 &= ~OFIFG;
> > BCSCTL2 |= SELM_3;
> > _BIS_SR(SCG0 + SCG1); //written to disable DCO
> >
> > for(int i=0;i<50;i++)
> > {
> > P1OUT ^= 0x81;
> > }
> > for(int i=0;i<100;i++)
> > {}
> > P1OUT ^= 0x81;
> >
> > _BIC_SR(SCG0 + SCG1); //written to enable DCO
> > BCSCTL2 = 0x00;
> > BCSCTL3 = 0x04;
> > for(int i=0;i<300;i++)
> > {
> > P1OUT ^= 0x81;
> > }
> > }
> >
> >
> > I have observed from an oscilloscope that while the clock source is
> > getting changed the DCO is not getting disabled since the program sets
> > DCO again even when the _BIC_SR(SCG0 + SCG1); command is commented.
> > I have inserted a breakpoint to check if SCG bits are set after the
> > command is executed by observing the register values in IAR. The bits
> > are set correctly.
> >
> > I would be glad if anyone could help me out with this problem.
> >
> > Thanking you
> > Harish
> >
>

Memfault Beyond the Launch