I am using MC9S12G processor and want to enter a low power mode where i want to perform two I/O operations
1. Watchdog trigger(Using DIO)
2. LED (Using DIO))
I tried the stop instruction and find that the Core is not executing any instruction after asm STOP.
Is there any other way possible to go to low power mode with above requirement.
In the S12G family, the easiest way to periodically exit STOP mode is to use the Autonomous Periodical Interrupt (API) timer contained in the Clock, Reset and Power Management Unit (CPMU) module. The API timer consists of a low power RC oscillator and a 16-bit timeout register. Timeout periods can be selected from 0.2 mS - 13107.2 mS in 0.2 mS increments.
So, the API timer can be used to exit STOP to trigger the external Watchdog and blink the LED. The CPU can then reenter STOP mode and wait for the next API interrupt.
In attachment you can see simple example code for periodical wake up from stop mode (G240-API+STOP-CW51).
Note: API RC oscillator (10kHz) isn’t trimmed from factory. There isn’t any universal setting; every MCU should be trimmed separately. Accuracy of trimmed API clock source is defined as +/-5%. In attachment you can see simple example code for API trimming (G240-API-CW51)
S12CPMU core on S12G MCU supports following modes of operation:
Refer to chapter 10.1.2 Modes of Operation of the S12G reference manula (link below)
For your case, you can either use run mode with low bus clock frequency for low power consumption, or enter into STOP or WAI mode and wait for an interrupt to wake up the MCU in order to do tasks.
In Wait mode the core runs (PLL is on), but you can set the peripheral's modes of operation i.e. low power options.
For example, the MSCAN has two additional modes with reduced power consumption, compared to normal mode: sleep and power down mode. In sleep mode, power consumption is reduced by stopping all clocks except those to access the registers from the CPU side. In power down mode, all clocks are stopped and no power is consumed.
The WAI instruction puts the MCU in a low power consumption stand-by mode. Additional power can be saved in power down mode because the CPU clocks are stopped. After leaving this power down mode, the MSCAN restarts and enters normal mode again. While the CPU is in wait mode, the MSCAN can be operated in normal mode and generate interrupts.