S12ZVL Lin Wake up from stop mode

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S12ZVL Lin Wake up from stop mode

Jump to solution
2,822 Views
alexishernandez
Contributor III

Hi community,
I've been trying to wake up the S12ZVL64 through LIN interface with really odd behaviours.
The module is able to wake up by the API and then it can return to stop mode without problems (because of this the logic of the non-Lin related code should be correct).
At this moment I don't have the API wake up (removed it to isolate the Lin issue), sometimes the microcontroller looks like being stucked into the SCI0 ISR (never returning to the main routine where the Stop mode was called), and some other times it looks like the system indeed returns to the main but do not answer to any Lin command.
I have the following questions related to the matter:
1.- When the system wake up from Stop mode, what is the status of the system ? (Some internal module needs to be re-initialized to work as before the Stop command)?
2.- Is there any special consideration for the LIN interface when the SCIACR1_RXEDGIE is set?
3.- Does the microcontroller needs any special command or is it enough with the toggle of the break in the signal?

Here I let you a snippet of the code:

/**********************************************************************************************************************/ 

Lin Init:

LP0CR_LPE = 1; // Enable LIN Phy
LP0CR_LPPUE = 1; // Pull up to strong signal
LP0CR_LPWUE = 1; // Enable Lin-Phy wakeup
LP0SLRM = 0x01;

/**********************************************************************************************************************/ 

Low Power routine:

SCI0CR1_WAKE = 1; /* Wake up SCI at an idle condition on the RXD pin */
SCI0SR2_AMAP = 1; /* Make SCIAxxx registers accessible */
SCI0ACR1_RXEDGIE = 1; /* Edge interrupt enabled for wake up */
SCI0ASR1_RXEDGIF = 1; /* Clear flag */
SCI0SR2_AMAP = 0; /* Make SCIAxxx registers inaccessible */
SCI0CR2_RWU = 0x01; /* SCI enters into standby state */

asm (ANDCC #0x7F); /* Enable Stop mode */
__asm (STOP); /* Enter Stop mode */


/**********************************************************************************************************************/
SCI0_ISR:

ISR(VectorNumber_Vsci0, SCI0_INT)
{
SCI0SR2_AMAP = 1; /* Make SCIAxxx registers accessible */
SCI0ACR1_RXEDGIE = 0x00; /* Edge interrupt disabled for wake up */
SCI0ASR1_RXEDGIF = 0x01; /* Clear flag */
//SCI0SR2_AMAP = 0; /* Make SCIAxxx registers inaccessible */

lin_lld_sci_isr(); /* Lin Driver routine*/
}

 

Best regards,
Alexis

Labels (1)
0 Kudos
1 Solution
2,012 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Alexis,
Could you attach the debugger to the MCU? It would be good to see where it is stucked.
What is the lin_lld_sci_isr() function?
There is no need to put the SCI module in the Standby mode.

A1. Please wait until PLL is locked.
A2. No
A3. If the LIN Physical Layer receives a dominant level longer than tWUFR followed by a rising edge, it sends a pulse to the SCI which can generate a wake-up interrupt.

Regards,
Daniel

View solution in original post

0 Kudos
3 Replies
2,013 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Alexis,
Could you attach the debugger to the MCU? It would be good to see where it is stucked.
What is the lin_lld_sci_isr() function?
There is no need to put the SCI module in the Standby mode.

A1. Please wait until PLL is locked.
A2. No
A3. If the LIN Physical Layer receives a dominant level longer than tWUFR followed by a rising edge, it sends a pulse to the SCI which can generate a wake-up interrupt.

Regards,
Daniel

0 Kudos
2,012 Views
alexishernandez
Contributor III

Hi Daniel,
I followed your recommendations and removed the Standby mode from SCI module, also It looks like the interruption flag was not cleared by the command, thus it did not leave the ISR: 
SCI0ASR1_RXEDGIF = 0x01; /* Clear flag */ 

had to change to:
SCI0ACR1 = 0x00;

The following configuration worked for me:

/**********************************************************************************************************************/ 

Lin Init:

void Init_Lin(void)
{
LP0CR = 0X0B;
LP0SLRM = 0x01;
}

/**********************************************************************************************************************/ 

Low Power routine:

DisableInterrupts;
__asm (ANDCC #0x7F); /* Enable Stop mode*/
LP0CR_LPWUE = 1;       /* Lin-Phy Enable*/
Shutdown_Lights();          /* Power off the hardware*/
SCI0SR2_AMAP = 1;        /* Make SCIAxxx registers accessible */ 
SCI0ASR1_RXEDGIF = 1; /* clear flag*/
SCI0ACR1_RXEDGIE = 1; /* edge interrupt enabled for wake up*/
EnableInterrupts;
__asm(STOP);

/**********************************************************************************************************************/ 
SCI0_ISR:

SCI0SR2_AMAP = 1;
SCI0ACR1 = 0x00;//SCI0ACR1_RXEDGIE_MASK;
lin_lld_sci_isr();

Find attached a working example of a demo using the Lin Wake up to restore the system from Stop mode.

Best regards,
Alexis



0 Kudos
2,012 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Alexis,

So you don't clear that flag at all now?  

You can stop the code in the ISR.

void SCI_RX_ISR(){

unsigned int i = 1;
 while(i);‍‍

...
}‍‍‍‍‍‍‍

Attach the debugger,

pastedImage_5.png

clear the 'i' variable to 0 in the Variable view,

step the code and check all the flags.

Regards,

Daniel

0 Kudos