A7130_WOR低功耗接收
本篇介紹A7130 WOR功能,關於什麼是Amiccom WOR之前很多篇都有介紹過了,這邊就不再贅述
Demo Code<
A7130-A01(A9108MCU) - WOR.zip>
"WOR_enable()" Function介紹:
設定GIO1為WTR Mode(此pin可以在WOR時觀察Sleep & active的時間間隔),設定GIO2為Wake up signal pin
需關閉CRC Check
A7130_WriteReg(GPIO1_REG, 0x01); //GIO1 as WTR A7130_WriteReg(GPIO2_REG, 0x11); //GIO2 as Wake up signal A7130_WriteReg(CODE1_REG,A7130Config[CODE1_REG]&0xEF); //Disable CRC
3.設定Sleep & Active time,進入Standby mode
A7130_WriteReg(RCOSC1_REG, 0x0A); //setup WOR Sleep time and RX time A7130_WriteReg(RCOSC2_REG, 0x14); StrobeCmd(CMD_STBY); //entry standby mode
4.校準RC OSC
//RC Calibration RCOSC_Calibration();
5.RC校準流程
Uint8 RCOSC_Calibration(void) { Uint8 tmp, rcoc, rcot, retry; for(rcot = 0; rcot < 4; rcot++) { for(retry = 0; retry < 3; retry ++) { A7130_WriteReg(RCOSC3_REG, 0x00); // RC-OSC disable A7130_WriteReg(RCOSC3_REG, (0x04 | (rcot << 4))); // RCOSC_E=1, CALW=0. RC-OSC enable (startup). rcoc = A7130_ReadReg(RCOSC1_REG); // read RCOC before calibration A7130_WriteReg(RCOSC3_REG, (0x0C | (rcot << 4))); // RCOSC_E=1, CALW=1. RC-OSC calibration begin. do { tmp = A7130_ReadReg(RCOSC3_REG) & 0x08; } while(tmp); // wait RC-OSC calibration finish. tmp = A7130_ReadReg(RCOSC1_REG); if(tmp != rcoc) // check RCOC. { rcoc = tmp; if(rcoc >= 20) { return 0; } } } } return 0xFF; }
6. WORE=1(Enable WOR),Wait GIO2 Go high(表示Wake up 成功)
A7130_WriteReg(MODECTRL_REG, A7130Config[MODECTRL_REG] | 0x08); //WORE=1 to enable WOR function while(GIO2==0); //Stay in WOR mode until receiving ID code(sync ok)
7.WORE=0(Disable WOR),& 調用RxPacket() Function 來Read RX Data Buffer
A7130_WriteReg(MODECTRL_REG, A7130Config[MODECTRL_REG]); //WORE=0 to disable WOR function RxPacket();