is it support sleep mode and wake-up function code in ProcessorExpert?
if it supported, how can i use?
mcu : S12ZVMC128
Codewarrior 10.7 version
Hi Byeongjin,
Since you wrote about sleep mode, I suppose that you question is related to MSCAN module.
The PE have an option for CAN Wakeup, but this option just affects WUPE and WUPM bits configuration. No specific code is generated.
Please look at attached simple example code for CAN wake-up.
Note: this example code was created for older S12XE MCU, but the MSCAN module is still the same.
The important code is:
//============
CANCTL0_WUPE = 1; //wake up enable
CANRIER_WUPIE = 1; //wake up interrupt enable
//============
and:
CANCTL0_SLPRQ = 1; //sleep mode request
while(CANCTL1_SLPAK == 0); //wait for acknowledge of sleep mode
asm ANDCC #0x7F; //clear S bit
asm nop;
asm STOP; //STOP mode
You should also create a wake-up ISR like:
interrupt VectorNumber_Vcan0wkup void CAN_WAKE(void)
{
//your code
CANRFLG=0x80 //clear WUPIF flag
CANRIER_WUPIE = 0; //wake up interrupt disable
}
I hope it helps you.
Have a great day,
Radek
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
i will using external pin port. (P port)
could i view example for pin interrupt wake-up and low-power mode?
Hi Byeongjin,
For example, wake-up by pin PP0
In main();
DDRP_DDRP0 = 0; //set PP0 as input
PPSP_PPSP0 = 0; //pull-up resistor is selected, falling edge selected
PERP_PERP0 = 1; //pull-up resistor is enabled
PIEP_PIEP0 = 1; //interrupt enabled
//…
EnableInterrupts;
//...
asm ANDCC #0x7F; //clear S bit
asm STOP; //STOP mode
//…You should here restore your configuration changed by stop mode enter like enable external oscillator or configure clock for RTI,…
//…
You should also create a wake-up ISR like:
interrupt VectorNumber_Vportp void PortP_ISR(void)
{
if(PIFP_PIFP0 == 1)
{
//your code
PIFP = 0x01; //clear the PIFP0 interrupt flag
}
}
I hope it helps you.
Have a great day,
Radek
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
thank you.
have a good day~