CAN wakeup in VLPR

cancel
Showing results for 
Search instead for 
Did you mean: 

CAN wakeup in VLPR

908 Views
shindeu66
Contributor III

Hello,

All,

I want to use Can wakeup functionality in VLPR mode with current consumption of less than 1mA for s32k116 MCU.

I am using PWM, LIN, CAN, Timer, Adc and digital pins for the project.

Can you please tell me the procedure for Can wakeup functionality in VLPR mode.

Thanks and Regards,

Shinde Umesh

Tags (2)
0 Kudos
3 Replies

694 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello shindeu66@gmail.com,
The VLPR mode is a RUN mode not a STOP mode.
And the FlexCAN module is fully functional in this mode.

pastedImage_1.png

pastedImage_3.png

However, in VLPR, the max SYS_CLK frequency is 4MHz.

pastedImage_4.png

pastedImage_5.png

Please note that the SIRC clock is not very precise:

pastedImage_6.png

Also, the specified consumption of S32K116 in VLPR is >1mA.

pastedImage_7.png

Please refer to the S32K1xx_Power_Modes_Configuration.xlsx file attached to the datasheet for information about use cases.

Regards,

Daniel

0 Kudos

694 Views
shindeu66
Contributor III

Hello,

Mr. Daniel,

  I have followed the example and procedure to enter into the VLPS that, before entering into VLPS FIRC and SOSC should be off and only SIRC should be running and also I converted the CAN rx pin as normal gpio pin for detecting the interrupt but its not detecting.

Can you please tell me what I am missing or doing wrong configuration while entering to RUN to VLPS.

And also when I am directly entering into the VLPS still the application code is in RUN condition.

So I am first entering into VLPR and then VLPS from it.

Please give the solution.

// Currently first entering into VLPR if some conditions are met.

void RUN_to_VLPR (void)
{
 INT8U mode;
 init_NVIC();
 mode = (SMC->PMSTAT & SMC_PMSTAT_PMSTAT_MASK) >> SMC_PMSTAT_PMSTAT_SHIFT;
 
 if((mode != VLPR_MODE))
 {
  b_PWRModeChg = OFF;
    CAN0->CTRL1   = CAN_CTRL1_CLKSRC(0); // CAN clock is configured as system clock
    SCG->SOSCCSR = SCG_SOSCCSR_SOSCCMRE(0); // disabled SCOSC monitor
    SCG->FIRCCSR = SCG_FIRCCSR_FIRCEN(0);          // disable FIRC
    SCG->SOSCCSR = SCG_SOSCCSR_SOSCEN(0);   // disabled  SOSC
    SMC->PMPROT |= SMC_PMPROT_AVLP(1);
  if(SMC->PMSTAT == RUN_MODE)
  {
   PMC->REGSC |= PMC_REGSC_BIASEN_MASK;
   SMC->PMCTRL = SMC_PMCTRL_RUNM(2);
   while(SMC->PMSTAT != 0x04);
  }
  f_OP_PWRMode = Md_vlpr;
  RUN_to_VLPS();
 }
}
void RUN_to_VLPS (void)
{
// DISABLE_INTERRUPTS();  // I think its not working
 INT8U mode;
// the below configuration is for configuring CANrx pin as gpio interrupt wakeup capable
 INT_SYS_EnableIRQ(PORT_IRQn);
 PINS_DRV_SetPinDirection(PTE, 4, GPIO_INPUT_DIRECTION);
 PINS_DRV_SetMuxModeSel(PORTE, 4, PORT_MUX_AS_GPIO);
 PINS_DRV_SetPinIntSel(PORTE, 4, PORT_INT_RISING_EDGE);;
 PINS_DRV_SetPullSel(PORTE, 4, PORT_INTERNAL_PULL_UP_ENABLED);
 
 mode = (SMC->PMSTAT & SMC_PMSTAT_PMSTAT_MASK) >> SMC_PMSTAT_PMSTAT_SHIFT;
  if(mode == VLPR_MODE)
  {
  init_SIRC();
  Goto_SIRC();
 
  S32_SCB ->SCR|=S32_SCB_SCR_SLEEPDEEP_MASK;
  SMC->PMPROT |= SMC_PMPROT_AVLP_MASK;
  SMC->PMCTRL=SMC_PMCTRL_STOPM(2);
  PMC->REGSC |= PMC_REGSC_BIASEN_MASK;
   }
/* Check if current mode is RUN mode */
 if(SMC->PMSTAT == VLPR_MODE)
 {
  /* Go to deep sleep mode */
  asm("WFI");
 }
}
void Goto_SIRC(void)
{
// is this required, as you did like this
    uint32_t srie = RCM->SRIE;
    RCM->SRIE = 0x0000;
    RCM->SRIE = 0xFFFF;
// taken from user manual of s32k
 SCG->RCCR = SCG_RCCR_SCS(2);
 SCG->RCCR = SCG_RCCR_DIVBUS(1);
 SCG->RCCR = SCG_RCCR_DIVSLOW(0);
 SCG->RCCR = SCG_RCCR_DIVSLOW(3);

      while(!((SCG->CSR & (0x0F000000)) & 0x02000000));
      while((SCG->SIRCCSR & (1 << 25)) == 0);
      RCM->SRIE = srie;
}
void init_SIRC(void)
{
    SCG->SIRCCSR &= ~ (1 << 24);
    SCG->SIRCCSR = SCG_SIRCCSR_SIRCEN(1);
    SCG->SIRCDIV |= 0x0404;
    while((SCG->SIRCCSR & (1 << 24)) == 0); // wait until clock is valid
    SCG->SIRCCSR |= (1 << 24);
}
// PORTE, PORTA
void init_NVIC(void)
{

    // PORT_interrupt
    S32_NVIC->ICPR[0] = (1 << 9);
    S32_NVIC->ISER[0] = (1 << 9);
    S32_NVIC->IPR[2] = S32_NVIC_IPR_PRI_1(1);  // Priority level 1
}

Thanks and Regards,

Shinde Umesh

0 Kudos

694 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello shindeu66@gmail.com,

Please test each function separately e.g. the interrupt in RUN mode.

It does not have to enter VLPR first, it can enter VLPS from RUN directly.

You cannot disable SOSC, FIRC, SPLL before SIRC is the system clock.

Please disconnect the debugger and power cycle the MCU so that the MCU can enter VLPS.

Measure the consumption of the MCU to see the state of the MCU.

You can also scope BYS_CLK on a CLKOUT pin, the BUS clock is gated off in the VLPS.

This Example S32K144 RTC VLPS S32DS.R1 utilizes the CLKOUT function.

Please disable the FlexCAN module before the transition to VLPS.

Thank you,

BR, Daniel 

0 Kudos