Waking up the MCU from Suspend Mode using the Capsense greater-than comparator interrupt
03/77/2010 | 04:31 AM
Problem
After the F800 MCU wakes up from Suspend Mode due to the Capsense greater-than comparator interrupt, the CS0CN register cannot be cleared immediately.
Solution
For the F800, a Capsense conversion takes 40uS per channel. Allowing the MCU to enter Suspend Mode during the Capsense conversion pushes the overall current consumption lower. To achieve that, enable the CS0 comparator and set the CS0TH to 0x0000. This allows the MCU to wake up from Suspend Mode after every Capsense conversion due to a greater-than comparator interrupt, since the CS0D (capsense result) will always be more than CS0TH (0x0000).
After the C8051F800 MCU wakes up from Suspend Mode due to the Capsense greater-than comparator interrupt, the CS0CN register can only be cleared after 2 system clock cycles. Code snippet is shown below:
CS0CN |= 0x10; // Start conversion OSCICN |= 0x20; // Place MCU in SUSPEND Mode, save current NOP(); // 2 NOPs required after SUSPEND Mode NOP(); // otherwise, cannot clear CS0 Conversion Complete interrupt flag // and CS0 Greater Than interrupt flag
CS0CN &= ~0x21; // Clear CS0 Greater than interrupt flag and conversion complete flag
Alternatively, the flags can be cleared before starting a conversion. Code snippet is shown below: CS0CN &= ~0x21; // Clear CS0 Greater than interrupt flag and conversion complete flag CS0CN |= 0x10; // Start conversion OSCICN |= 0x20; // Place MCU in SUSPEND Mode, save current
This issue does not occur in the F700 MCU due to the need for a SFR page change for the F700 MCU. Code snippet for the F700 is shown below: CS0CN |= 0x10; // Start conversion
SFRPAGE = CONFIG_PAGE; OSCICN |= 0x20; // Place MCU in suspend mode SFRPAGE = LEGACY_PAGE; // This involves a MOV instruction which takes up 2 machine cycles
CS0CN &= ~0x21; // Clear CS0 Greater than interrupt flag and conversion complete flag
Waking up the MCU from Suspend Mode using the Capsense greater-than comparator interrupt