Not able to wakeup device from sleep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I am using fallowing config in my code , but once i entered sleep mode, the device is not getting wake up. I am using only internal clock in my board.
#pragma CODE_SEG NON_BANKED
#pragma TRAP_PROC
void interrupt VectorNumber_Vportp PORTPP_ISR(void)
{
unsigned char i=0;
rx_cnt=0;
interrupt_Flag = 1;
do
{
while(SPI1SR_SPIF == 0);
rx_data[rx_cnt] = SPI1DRL;
} while(rx_data[rx_cnt++]!=0xAB);
}
PIFP=0x01; //Clear the interrupt flag |
}
#pragma CODE_SEG DEFAULT
void main(void)
{
unsigned int i=0;
// clock initialization
ECLKCTL_NECLK = 0; /* Enable ECLK = Bus Clock */
CPMUPROT = 0x26; /* Disable protection of clock configuration registers */
CPMUCLKS_PSTP = 0;
CPMUCLKS_PLLSEL = 1; /* Enable the PLL to allow write to divider registers */
CPMUSYNR = 0x58; /* Set the multiplier register */
CPMUPOSTDIV = 0x00; /* Set the post divider register */
CPMUREFDIV=0x00; //ABP
CPMUPLL = 0x00; /* Set the PLL frequency modulation */
while(!CPMUFLG_LOCK) { /* Wait until the PLL is within the desired tolerance of the target frequency */
}
CPMUPROT=0x00; /* Enable protection of clock configuration registers */
/***Interrupt pin configure****/
DDRP_DDRP0=0; // make as input
PERP_PERP0=1; // pull up enable
PPSP_PPSP0=0;
PIEP_PIEP0=1;
while(1)
{
static int k=0;
/***Controller all devices only when ign on ****/
if(interrupt_flag == TRUE)
{
//Do some task
}
else
{
// CPMUCLKS_COPOSCSEL1=1;
//DisplayString_deb("Bye\r\n");
CPMUCLKS_PSTP = 0; /* Set PSTP bit to enable Pseudo Stop Mode */
asm ANDCC #0x7F; /* Clear S-bit in the CCR to enable STOP instruction */
asm STOP; /* Enter Pseudo Stop mode */
//asm WAI; /* Enter Wait mode */
}
}/* Loop Forever.Code should never reach here */
But i am not able to wake up the device once enters in to sleep mode. Kindly help me regarding this. I want to reduce max current from primary controller. let me know what all things need to check to reduce max current. Any register need to set to make device to wake up from sleep?


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Punith,
It seems, that you just forget to enable I-bit maskable interrupts (clear I-bit).
Please add command “EnableInterrupts;” into your main() code.
Note: the macro EnableInterrupts is defined in hidef.h file as:
#define EnableInterrupts {__asm CLI;}
So, the command “EnableInterrupts;” is equal to “asm CLI;” or “asm ANDCC #0xEF;” commands.
Note: write into CPMUCLKS_PSTP is not possible when the clock configuration is protected.
Note: The S-bit is cleared by “asm ANDCC #0x7F;” and set by next MCU reset. So, you don’t need to execute “asm ANDCC #0x7F;” command prior every STOP instruction. You could move it into initialization code.
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!
-----------------------------------------------------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to enable the PTC0 XIRQ interrupt for S9S12GA240 controller. I need to
use this pin as interrupt pin since there is no interrupt enable register
for PORT T, how to do this.
On Mon, Aug 1, 2016 at 1:35 PM, RadekS <admin@community.freescale.com>


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Punith,
The XIRQ interrupt is enabled by clearing the X mask bit in the CPU Condition Code register. The I/O state of the pin is forced to input level upon the first clearing of the X bit and held in this state even if the bit is set again. Software cannot set the X-bit from 0 to 1 once it has been cleared, and interrupt requests made via the XIRQ pin become non-maskable.
The command for clearing X bit in CCR register is:
asm ANDCC #0xBF;
CPU S12Z Reference manual:
http://www.nxp.com/files/microcontrollers/doc/ref_manual/S12ZCPU_RM_V1.pdf
You are right that there isn’t port interrupt for port T. However, you can still initialize and configure appropriate timer channel as input capture mode. As an advantage, you may detect both type of edges (rising and falling) simultaneously by this way and you will get an interrupt specific for the single pin instead of port. Of course, this is available only in the case when not all timer's channels are in use.
BTW: Are you able now to wake-up MCU by port P interrupt (when you clear I bit)?
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!
-----------------------------------------------------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry for confusing here, Yes I am able to wake the CPU from sleep by using
port p. Could you give sample code for PT0 pin to configure as interrupt
along wint interrupt handler functional. I want to use that PTC0 pin as
interrupt for other function.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Punith,
I am sorry for my delay and misleading information.
Unfortunately, timer interrupt cannot be used for wake-up from STOP mode. The source clock for the timer is Bus clock which is disabled in STOP mode.
The timer interrupt could wake-up only from WAIT mode.
So, you might use timer interrupt as pin interrupt, however, there isn’t wake-up capability from STOP mode.
Attached is simple example code tor timer in input capture mode (used for period measurement).
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!
-----------------------------------------------------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes. I am not wakeup CPU from sleep by using port p. Could you give sample
code for PT0 pin to configure as interrupt along wint interrupt handler
functiona.
