Dears,
I am working with a MC9S12ZVL and I have a problem when I try to put the micro in stop mode.
The command "asm STOP" has no effects. Probably I need to set some registers but I don't know which ones. I tried to set some bits of the CPMUCLK and CPMUINT registers without getting any results.
The second problem regards the WAIT mode. I put the micro in wait using "asm WAI" but I can't wake up it using the PAD port as KWU.
Could you give me any suggestions?
thanks in advance
Fabrizio
解決済! 解決策の投稿を見る。
Hi Fabrizio,
Prior to executing stop command, the S bit in CCR must be cleared to enable the stop mode. If the S bit is not cleared, then STOP instruction has no effect and it is executed as a dummy instruction NOP.
asm ANDCC #0x7F; //clear S bit - enable the stop mode.
I have attached a simple example code of Stop mode made for S12ZVM, but the main code can be used with S12ZVL as well.
It uses IRQ pin as a trigger to wake up the MCU. When th epin is triggered by falling edge, the MCU goes out of Stop mode into interrupt routine and then after into Stop mode again (kind of loop).
The interrupt routine is indicated by several LED blinks which is done by toggling Port T.
The TRK-S12ZVL board has user RGB LEDs connected to Port P and the LEDs should light when there is logic zero on the port pins.
Regarding the wake up from WAIT mode by KWU, a pin interrupt must be activated. There is a Port Interrupt Enable Register and for the Port AD it is PIEADH/PIEADL exactly. So you should set the bits in this register to logic 1 to enable interrupts.
Regards,
iggi
Hi Fabrizio,
Prior to executing stop command, the S bit in CCR must be cleared to enable the stop mode. If the S bit is not cleared, then STOP instruction has no effect and it is executed as a dummy instruction NOP.
asm ANDCC #0x7F; //clear S bit - enable the stop mode.
I have attached a simple example code of Stop mode made for S12ZVM, but the main code can be used with S12ZVL as well.
It uses IRQ pin as a trigger to wake up the MCU. When th epin is triggered by falling edge, the MCU goes out of Stop mode into interrupt routine and then after into Stop mode again (kind of loop).
The interrupt routine is indicated by several LED blinks which is done by toggling Port T.
The TRK-S12ZVL board has user RGB LEDs connected to Port P and the LEDs should light when there is logic zero on the port pins.
Regarding the wake up from WAIT mode by KWU, a pin interrupt must be activated. There is a Port Interrupt Enable Register and for the Port AD it is PIEADH/PIEADL exactly. So you should set the bits in this register to logic 1 to enable interrupts.
Regards,
iggi
Thanks a lot Iggi,
now I am able to put in STOP mode the device, but I cannot wake up it.
I have enabled the bit PIEADL/H of Port Interrupt Enable Register for the Port AD but it has no effect on the wake up of the device.
Could you confirm that it is possible to wake up the device from STOP mode using the KWU interrupt of port AD and port L?
Is there any other asm instruction that I need for the wake up?
Where have you found the asm instruction for the STOP mode asm ANDCC #0x7F to clear the S bit?
I am afraid that I miss a manual where the asm instructions are contained.
Thank you for the help
Best regards
Fabrizio
Hi,
In stop mode, the INT module is capable of waking up the CPU if an eligible CPU exception occurs.
Every I-bit maskable interrupt request which is configured to be handled by the CPU is capable of waking
the MCU from stop or wait mode. Additionally machine exceptions can wake-up the MCU from stop or
wait mode.
To determine whether an I-bit maskable interrupts is qualified to wake up the CPU or not, the same settings
as in normal run mode are applied during stop or wait mode:
• If the I-bit in the CCW is set, all I-bit maskable interrupts are masked from waking up the MCU.
• An I-bit maskable interrupt is ignored if it is configured to a priority level below or equal to the current IPL in CCW.
The X-bit maskable interrupt request can wake up the MCU from stop or wait mode at anytime, even if
the X-bit in CCW is set1. If the X-bit maskable interrupt request is used to wake-up the MCU with the Xbit
in the CCW set, the associated ISR is not called. The CPU then resumes program execution with the
instruction following the WAI or STOP instruction. This feature works following the same rules like any
interrupt request, i.e. care must be taken that the X-bit maskable interrupt request used for wake-up
remains active at least until the system begins execution of the instruction following the WAI or STOP
instruction; otherwise, wake-up may not occur.
Hi Martin,
Thanks for your guidance.
I understood now from the datasheet.