I don't understand how the line
"SLEEPCMD &= ~SLEEP_OSC_PD_BM; // power up both oscillators"
in the following function works... can some one help me?
This is a sample code from the cc2530 sample examples (Components\radios\cc2530\clock.c)
void clockSetMainSrc(uint8 source)
{
register uint8 osc32k_bm = CLKCONCMD & CLKCON_OSC32K_BM;
// Source can have the following values:
// CLOCK_SRC_XOSC 0x00 High speed Crystal Oscillator (XOSC)
// CLOCK_SRC_HFRC 0x01 Low power RC Oscillator (HFRC)
SLEEPCMD &= ~SLEEP_OSC_PD_BM; // power up both oscillators
while (!CC2530_IS_HFRC_STABLE() || ((SLEEPSTA & SLEEP_OSC_PD_BM)!=0));// wait until the oscillator is stable
NOP();
if (source == CLOCK_SRC_HFRC){
CLKCONCMD = (osc32k_bm | CLKCON_OSC_BM | TICKSPD_DIV_2 | CLKCON_CLKSPD_BM);
}
else if (source == CLOCK_SRC_XOSC){
CLKCONCMD = (osc32k_bm | TICKSPD_DIV_1);
}
CC2530_WAIT_CLK_UPDATE();
SLEEPCMD |= SLEEP_OSC_PD_BM; // power down the unused oscillator
}
i m refering swru191b.pdf (cc253x user manual)
this is the sleepcmd register description :
SLEEPCMD (0xBE) – Sleep-Mode Control Command
Bit description/value
7 OSC32K_CALDIS 0 R/W Disable 32-kHz RC oscillator calibration
0: 32-kHz RC oscillator calibration is enabled.
1: 32-kHz RC oscillator calibration is disabled.
This setting can be written at any time, but does not take effect before the chip has
been running on the 16-MHz high-frequency RC oscillator.
6:3 – 000 0 R0 Reserved
2 – 1 R/W Reserved. Always write as 1
1:0 MODE[1:0] 00 R/W Power-mode setting
00: Active / Idle mode
01: Power mode 1 (PM1)
10: Power mode 2 (PM2)
11: Power mode 3 (PM3)
and
#define SLEEP_OSC_PD_BM 0x04
and,
SLEEPCMD.OSC_PD this as seen in Figure 4-1. Clock System Overview.
The OSC_PD is not defined in the register definition of SLEEPCMD.