CC1110 pm3 唤醒不能发送数据
HI:
我在用cc1110做一个项目,要做到超低功耗。芯片pm3睡眠。外部io p1.中断唤醒。按照DN106上面做的 在休眠前切换晶振。开启io口中断。唤醒过后切换回hs xosc 但是不能发送数据。有遇到同样的问题的吗?
void enterPM3(void)
{
unsigned char temp;
unsigned short desired_event0 =0x876b ;
//switch from HS XOSC to HS RCOSC
// Power up [HS RCOSC] (SLEEP.OSC_PD = 0)
SLEEP &= ~0x04;
// Wait until [HS RCOSC] is stable (SLEEP.HFRC_STB = 1)
while ( ! (SLEEP & 0x20) );
// Switch system clock source to HS RCOSC (CLKCON.OSC = 1),
// and set max CPU clock speed (CLKCON.CLKSPD = 1).
CLKCON = (CLKCON & ~0x07) | 0x40 | 0x01;
// Wait until system clock source has actually changed (CLKCON.OSC = 1)
while ( !(CLKCON & 0x40) );
// Power down [HS XOSC] (SLEEP.OSC_PD = 1)
SLEEP |= 0x04;
//////////////////////////////////////////////////////////////////////
// Setup + enable the interrupt source(s) (Sleep Timer, Port) which is/are
// intended to wake-up the SoC from PM.
//////////////////////////////////////////////////////////////////////
P1IEN |= 0xf0;
PICTL |= 0x1f; /*Port2 interrupt disabled, |=0x20.enabled.*/
IEN2 |= 0x10; /*Port 1(0x10) interrupt enabled. */
IEN1 |= 0x20; /*Port 0(0x20) interrupt enabled.*/
sleepStatus = true;
IEN1 &= ~0x10; //disable timer 4 interrupt
WDCTL = 0x00; //Enable WDT,about 1s,WDT mode.
WDCTL &=~0x08; //disable WDT
// Store current DMA channel 2 descriptor and abort any ongoing transfers,
// if the channel is in use.
unsigned char storedDescHigh = DMA0CFGH;
unsigned char storedDescLow = DMA0CFGL;
DMAARM |= 0x81; //0x81 channel 0;84 channel 2
// Update descriptor with correct source.
// NB! Replace &PM2_BUF with &PM3_BUF if powermode 3 is chosen instead.
dmaDesc[0] = (unsigned int)& PM3_BUF >> 8;
dmaDesc[1] = (unsigned int)& PM3_BUF;
// Associate the descriptor with DMA channel 2 and arm the DMA channel
DMA0CFGH = (unsigned int)&dmaDesc >> 8;
DMA0CFGL = (unsigned int)&dmaDesc;
DMAARM = 0x01;
////////////////////////////////////////////////////////////////////////////
// NOTE! At this point, make sure all interrupts that will not be used to
// wake from PM are disabled as described in the "Power Management Control"
// chapter of the data sheet.
// The following code is timing critical and should be done in the
// order as shown here with no intervening code.
// Align with positive 32 kHz clock edge as described in the
// "Sleep Timer and Power Modes" chapter of the data sheet.
// temp = WORTIME0;
// while(temp == WORTIME0);
// Make sure XOSC is powered down when entering PM{2 - 3} and that the
// flash cache is disabled.
// NB! Replace 0x06 with 0x07 if power mode 3 is chosen instead.
MEMCTR |= 0x02;
SLEEP = 0x07;
// Enter power mode as described in chapter "Power Management Control"
// in the data sheet. Make sure DMA channel 0 is triggered just before
// setting PCON.IDLE.
asm("NOP");
asm("NOP");
asm("NOP");
if(SLEEP & 0x03)
{
asm("MOV 0xD7,#0x01"); // DMAREQ = 0x01;
asm("NOP"); // Needed to perfectly align the DMA transfer.
asm("ORL 0x87,#0x01"); // PCON |= 0x01;
asm("NOP");
}
// End of timing critical code
////////////////////////////////////////////////////////////////////////////
// Enable Flash Cache.
MEMCTR &= ~0x02;
// Update DMA channel 2 with original descriptor and arm channel if it was
// in use before PM was entered.
DMA0CFGH = storedDescHigh;
DMA0CFGL = storedDescLow;
DMAARM = 0x01;
////////////////////////////////////////////////////////////////////
////////////////////// Code section end ////////////////////////////
////////////////////////////////////////////////////////////////////
//wake up now.switch from HS RCOSC to HS XOSC
// Power up [HS XOSC] (SLEEP.OSC_PD = 0)
SLEEP &= ~0x04;
// Wait until [HS XOSC] is stable (SLEEP.XOSC_STB = 1)
while ( ! (SLEEP & 0x40) );
// Switch system clock source to [HS XOSC] (CLKCON.OSC = 0)
CLKCON &= ~0x40;
// Wait until system clock source has actually changed (CLKCON.OSC = 0)
while ( CLKCON & 0x40 );
// Power down [HS RCOSC] (SLEEP.OSC_PD = 1)
SLEEP |= 0x04;
}
切换回 XOSC 后有做Calibration 吗?
如何做校正?请指教
例程里面 Tx 发送那个函数里面应该有。也是一个 Strobe Command。
HI:我按照你说的加了如下的代码
SIDLE();
SCAL();
/while (MARCSTATE != MARCSTATE_IDLE); // Wait for calibration to complete
但是唤醒过后还是不能正常数据,请问是否还有其他原因?
不能正常发的现象具体是怎样的?射频口有信号出来吗?还是不能进入发送状态?有信号出来可以用示波器看看频率是不是有问题。