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.

CC2500: CC2500

Part Number: CC2500
Other Parts Discussed in Thread: MSP430G2433,

在对CC2500发送sleep命令之后,我们发现它有时候并没有进入sleep状态,这导致我们的产品耗电速度加快。查看芯片手册,发现CC2500没有提供sleep状态的某些反馈查询手段,所以目前无法确定CC2500是否进入sleep状态。以上情况概率性发生,我们将MCU睡眠,而刻意不发送sleep命令,能百分之百复现上述情况。低功耗电流为1.7mA,故此,我们认为芯片未进入sleep状态。想请问,CC2500的sleep命令,是否需要注意某些特定操作步骤或者时序问题。相关代码,我贴在下面。MCU用的MSP430G2433,系统关机之前,采用看门狗复位方式,从mian函数开头进入休眠。

void main(void)
{
	WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer
	IFG1 = 0;
	CLK_init(); 
	Port_init();
	memset(id, 0xff, sizeof(id));
	read_array((unsigned char *) FLASH_ADDRESS, id, sizeof(id));
	// If the work mode in flash is empty, just use the default one.
	if (FALSE == CheckValidInFlash())
	{
		restore_saving_data();
	}	
	adc_off();
	PWM_Init();
	Unit_Init();        
        
    SPI_Init();
    CC2500_Init();
    CC2500_Write_RxADDR();            
    CC2500_Command(CCxxx0_SPWD);             //CC2500 Sleep

	if(((P2IN & PRECHARGE_STATE) ==PRECHARGE_STATE))  // no charge battery tonya
	{ 
#if AUTO_TURN_ON_IN_ABNORMAL_SHUTDOWN
		if (id[DEVICE_AVOID_ESD] == KEEP_WORKING_AFTER_ABNORMAL_SHUTDOWN_FLAG_OFF)
#endif
		{
			_BIS_SR(LPM4_bits + GIE);                           // Enter LPM4 w/interrupt
		}
	}
	else
	{                         
#if DEVICE_LOCK_FUNCTION
		id[DEVICE_LOCK_STATE] = UINT_UNLOCK;                         // Release key lock
#endif
#if AUTO_TURN_ON_IN_ABNORMAL_SHUTDOWN
		id[DEVICE_AVOID_ESD] = KEEP_WORKING_AFTER_ABNORMAL_SHUTDOWN_FLAG_OFF;
#endif
                id[LOW_POWER_INDICATOR_FLAG] = LOW_POWER_INDICATOR_FLAG_OFF;
                
		__disable_interrupt();
		flash_erase( (unsigned int *) FLASH_ADDRESS);
		write_array((unsigned char *) FLASH_ADDRESS, id, sizeof(id));

		Delay_ms(5);
		ChargeFlag=1;
		ChargeState = CHARGING_NOT_IN_STATUS;
		_BIS_SR(GIE);                                       // Enter interrupt

	}
}

void CC2500_Init(void) 
{
  unsigned char temp;
	CSN_ON(); 
	delay_ms(1);
	CSN_OFF(); 
	delay_ms(1);
	CSN_ON(); 
	delay_ms(1);

	CSN_OFF();
	SPI_Write(CCxxx0_SRES); 		//write reset command
	CSN_ON(); 
    do{
	CC2500_WriteReg(CCxxx0_FSCTRL1,  CC2500_Config.FSCTRL1);
	CC2500_WriteReg(CCxxx0_FSCTRL0,  CC2500_Config.FSCTRL0);
	CC2500_WriteReg(CCxxx0_FREQ2,    CC2500_Config.FREQ2);
	CC2500_WriteReg(CCxxx0_FREQ1,    CC2500_Config.FREQ1);
	CC2500_WriteReg(CCxxx0_FREQ0,    CC2500_Config.FREQ0);
	CC2500_WriteReg(CCxxx0_MDMCFG4,  CC2500_Config.MDMCFG4);
	CC2500_WriteReg(CCxxx0_MDMCFG3,  CC2500_Config.MDMCFG3);
	CC2500_WriteReg(CCxxx0_MDMCFG2,  CC2500_Config.MDMCFG2);
	CC2500_WriteReg(CCxxx0_MDMCFG1,  CC2500_Config.MDMCFG1);
	CC2500_WriteReg(CCxxx0_MDMCFG0,  CC2500_Config.MDMCFG0);
	CC2500_WriteReg(CCxxx0_CHANNR,   CC2500_Config.CHANNR);
	CC2500_WriteReg(CCxxx0_DEVIATN,  CC2500_Config.DEVIATN);
	CC2500_WriteReg(CCxxx0_FREND1,   CC2500_Config.FREND1);
	CC2500_WriteReg(CCxxx0_FREND0,   CC2500_Config.FREND0);
	CC2500_WriteReg(CCxxx0_MCSM0 ,   CC2500_Config.MCSM0 );
	CC2500_WriteReg(CCxxx0_FOCCFG,   CC2500_Config.FOCCFG);
	CC2500_WriteReg(CCxxx0_BSCFG,    CC2500_Config.BSCFG);
	CC2500_WriteReg(CCxxx0_AGCCTRL2, CC2500_Config.AGCCTRL2);
	CC2500_WriteReg(CCxxx0_AGCCTRL1, CC2500_Config.AGCCTRL1);
	CC2500_WriteReg(CCxxx0_AGCCTRL0, CC2500_Config.AGCCTRL0);
	CC2500_WriteReg(CCxxx0_FSCAL3,   CC2500_Config.FSCAL3);
	CC2500_WriteReg(CCxxx0_FSCAL2,   CC2500_Config.FSCAL2);
	CC2500_WriteReg(CCxxx0_FSCAL1,   CC2500_Config.FSCAL1);
	CC2500_WriteReg(CCxxx0_FSCAL0,   CC2500_Config.FSCAL0);
	CC2500_WriteReg(CCxxx0_FSTEST,   CC2500_Config.FSTEST);
	CC2500_WriteReg(CCxxx0_TEST2,    CC2500_Config.TEST2);
	CC2500_WriteReg(CCxxx0_TEST1,    CC2500_Config.TEST1);
	CC2500_WriteReg(CCxxx0_TEST0,    CC2500_Config.TEST0);
	CC2500_WriteReg(CCxxx0_IOCFG2,   CC2500_Config.IOCFG2);
	CC2500_WriteReg(CCxxx0_IOCFG0,   CC2500_Config.IOCFG0);    
	CC2500_WriteReg(CCxxx0_PKTCTRL1, CC2500_Config.PKTCTRL1);
	CC2500_WriteReg(CCxxx0_PKTCTRL0, CC2500_Config.PKTCTRL0);
	CC2500_WriteReg(CCxxx0_ADDR,     CC2500_Config.ADDR);
	CC2500_WriteReg(CCxxx0_PKTLEN,   CC2500_Config.PKTLEN);
    CC2500_WritePaTable(CCxxx0_PATABLE,PaTabel); //to set output power  
        
    temp = CC2500_ReadReg(CCxxx0_FREQ0);
    }while(temp!=CC2500_Config.FREQ0); 
        
	CC2500_Command(CCxxx0_SFRX);
	CC2500_Command(CCxxx0_SFTX);
	CC2500_Command(CCxxx0_SIDLE);
}

void CC2500_Command(uint8 cmd) 
{
	CSN_OFF();
	while (MISO_IN);
	SPI_Write(cmd);		
	CSN_ON();
}