Other Parts Discussed in Thread: , SMARTRF06EBK, , SIMPLELINK-2-4GHZ-DESIGN-REVIEWS,
Hi,
My customers are developing products that use CC2538.
CC2538 custom board
CC2538-SW 1.0.1.0
In vary rare cases, CC2538 will not wake up from "Power Mode 2".
They get the value of the Sleep Timer and store the value after about 20ms in the Compare register. CC2538 usually wake up, but very rarely does not.
Example code created by customers is shown below. (msec is 16~24ms.)
ApiResult_t ApiSleep(uint16_t msec) { uint32_t ui32Val; uint32_t ui32Diff; ui32Diff = (uint32_t)msec; ui32Diff = (ui32Diff * 32768UL) / 1000UL; //msec -> Tick // Disable other interrupts SysTickIntDisable(); // Disable SysTick timer interrupt UARTIntDisable(UART0_BASE, UART_INT_RX | UART_INT_RT); // Disable UART RX interrupt UARTAbortTx(); // Disable UART TX interrupt // Let system enter powermode 2 when going to deep sleep SysCtrlPowerModeSet(SYS_CTRL_PM_2); // Enable the Sleep Timer wakeup GPIOIntWakeupEnable(GPIO_IWE_SM_TIMER); // Enable sleep mode interrupt IntEnable(INT_SMTIM); // Set timer to ui32Diff above current value ui32Val = SleepModeTimerCountGet(); SleepModeTimerCompareSet(ui32Val + ui32Diff); // Go to sleep SysCtrlDeepSleep(); // Enable other interrupts SysTickIntEnable(); // Enable SysTick timer interrupt UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); // Enable UART RX interrupt … }
The above code complies with the restrictions of User's Guide 13.2 Timer Compare.
「When setting a new compare value, the value must be at least 5 more than the current sleep timer value. Otherwise, the timer compare event may be lost.」
Strangely enough, the device that didn't wake up in 20ms was confirmed to wake up when the SleepTimer went around. (After about 36.4 hours, 32kHz, 32bit register)
The device was probably woken up at the second timing when the Sleep Timer and the Compare value matched.
This leads us to believe that SleepTimer misses the Compare event very rarely.
Question 1:
Please let me know if you know the cause and what to do.
Question 2:
I believe that when a value greater than 32 bits is written (overflow), the timer starts counting again from 0x0000 0000. Is this correct?
(Example) If compare value = 5+Sleep timer
Sleep Timer Timer Compare
0x0000 0000 0x0000 0005
0xFFFF FFFA 0xFFFF FFFF
0xFFFF FFFB 0x0000 0000
0xFFFF FFFC 0x0000 0001
Regards,
Rei