工具与软件:


void CC1101_Write_Cmd_SWOR(void)
{
//__istate_t isate = __get_interrupt_state();__disable_interrupt();
DisableInterruptsAndSaveState();
// Every 4 th time when going from RX or TX to IDLE automatically
//CC1101_Write_Reg(CC1101_MCSM0, 0x38); //PO_TIMEOUT[10] :Approx. 149 – 155 μs
CC1101_Write_Reg(CC1101_MCSM0, 0x3C); //PO_TIMEOUT[10]: 3 (11) 256 Approx. 597 – 620 μs
//TX1_TOGGLE;
if (WOR_short)
{
//RX_timeout =tevent0 * RX_TIME = 50ms*3.125% = 1.5625ms
CC1101_Write_Reg(CC1101_MCSM2, 0x11); // 0x10 50ms*3.125% = 1.5625ms
//sl_p = (uint32_t)(50 * 26000 / 750); //0x06C5
CC1101_Write_Reg(CC1101_WOREVT1, 0x06); // Event0高8位 50ms
CC1101_Write_Reg(CC1101_WOREVT0, 0xC5); // Event0低8位
}
else
{
CC1101_Write_Reg(CC1101_MCSM2, 0x16); // 1000ms*0.195%=1.95ms
CC1101_Write_Reg(CC1101_WOREVT1,0x87);//Event0高8位 1000ms
CC1101_Write_Reg(CC1101_WOREVT0,0x6A);//Event0低8位
}
CC1101_Write_Reg(CC1101_WORCTRL, 0x58);//WOR_RES = 0 Max:1.8 – 1.9 seconds
//tevent1 = 12*750/2M = 346us
Delay_Ms(4);//2ms校准时间
//bug4:WOR timing error on short timing intervals
CC1101_Write_Reg(CC1101_IOCFG0, 0x27); // 0x27:CLK_32k 34.66KHz 推断晶振为26Mhz
//tsleep = tevent0(999/50ms) - tevent1(346.15) - tidletorx/cal(799) -trx_timeout - tidle(150us)
//WOR_short:1 trx_timeout = 1.5625ms tsleep= 50ms-0.34615-0.799-1.5625-0.15 = 47.14235 ms
//WOR_short:0 trx_timeout = 1.95ms tsleep= 1000ms-0.34615-0.799-1.95-0.15 = 996.75485 ms
//t SLEEP >t SLEEP min tsleepmin = 750*384/26MHz = 11.0769ms
//WOR_short:1: tevent0 - tsleepmin = 50 -11.08 = 38.92ms
//WOR_short:0: tevent0 - tsleepmin = 1000 -11.08 = 988.92ms
//WOR_short:1 x= 1349 WOR_short:0 x=34282 x*750/26000000 = 38.92 /988.92ms
while(1)
{
if(GDO0_IN == 0)
{
wortime = CC1101_Read_Status(CC1101_WORTIME0);
wortime |= CC1101_Read_Status(CC1101_WORTIME1)<<8;
if(WOR_short && wortime < 1300)
{
break;
}
if((WOR_short == 0) && wortime < 34000)
{
break;
}
}
}
//bug7:WOR Timer Issue when RCOSC Calibration is Disabled WOR timer runs too slow
CC1101_Write_Reg(CC1101_IOCFG0, 0x26); // 0x26:CLK_256
//CC1101_Write_Reg(CC1101_WORCTRL, 0x38); // 事件 1 工作暂停前事件 0 后 WOR_RES==0 1LSB周期 (27μs – 31μs)
//EVENT1[2:0]=4(100) tevnet1= 0.444~0.462ms
//tEvent1 > Max XOSC Startup + PO_TIMEOUT? XOSC Startup:150us
CC1101_Write_Reg(CC1101_WORCTRL, 0x50);
uint8_t calib1 = CC1101_Read_Status(RCCTRL1_STATUS);
uint8_t calib0 = CC1101_Read_Status(RCCTRL0_STATUS);
CC1101_Write_Reg(CC1101_RCCTRL1, calib1);
CC1101_Write_Reg(CC1101_RCCTRL0, calib0);
// while(1)
// {
// if(GDO0_IN == 0)
// break;
// }
while(GDO0_IN);
//CC1101_Write_Reg(CC1101_IOCFG0, 0x24); // 0x24 WOR_ENVT0
//CC1101_Write_Reg(CC1101_IOCFG0, 0x25); // 0x25 WOR_ENVT1
CC1101_Write_Reg(CC1101_IOCFG0, 0x2E); // 0x25 WOR_ENVT1
#ifdef EVNET_CHP_TEST
CC1101_Write_Reg(CC1101_IOCFG2, 0x25); // 0x25 WOR_ENVT1
CC1101_Write_Reg(CC1101_IOCFG0, 0x29); // 0x29 CHIP_RDYn
#endif
CC1101_Write_Cmd(CC1101_SWORRST); // Resets the real time clock
// This means that the strobe command must be executed in less than 1.84 ms
CC1101_Write_Cmd(CC1101_SWOR); // Starts Wake-on-Radi
//TX1_TOGGLE;
RestoreInterrupts();//__set_interrupt_state(isate);
}
消耗
