How to identify, which interrupt changed Power Mode from VLPS to RUN?

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

How to identify, which interrupt changed Power Mode from VLPS to RUN?

2,566 Views
akshaykul89
Contributor III

Hello,

In my project, I need to know, which interrupt caused the wake up of MCU from VLPS to RUN. There are few actions I need to perform, based on source of the wake-up. Any input or direction would be a great help. Some of the source for interrupt are,

- GPIO interrupt

- RTC alarm/timer interrupt

- ADC interrupt

One straight forward option I can think of is, manage some flag in all interrupt handlers which will be reset to default value before entering to VLPS. As soon as any interrupt is triggered, MCU moves to RUN mode. For the first ISR call, update the source of that interrupt with the flag. 

Later on, decision will be taken based in that flag. Is there any better/classic way to make it work ? may be some SDK API , MCU registers.

Thanks in advance. 

Regards,

Akshay K.#

Labels (1)
Tags (1)
9 Replies

2,159 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Akshay.

I think the solution you proposed is the right one.

You can capture the NVIC Interrupt Active Bit Registers or even better the S32_SCB->ICSR_VECTACTIVE vector number.

uint32_t awake = 0;
uint32_t vector_active = 0; // Vector number
uint32_t active[8];

/******************** ISRs *********************/
DISABLE_INTERRUPTS(); // __asm volatile ("cpsid i" : : : "memory");

 if(awake == 0)
 {

    vector_active = (S32_SCB->ICSR & S32_SCB_ICSR_VECTACTIVE_MASK);
    
    uint32_t i;
    for(i = 0; i < 8; i++)
    {
        active[i] = S32_NVIC->IABR[i];
    }

    awake = 1;
 }

ENABLE_INTERRUPTS(); //  __asm volatile ("cpsie i" : : : "memory");
/************************************************/

‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Regards,

Daniel

2,159 Views
akshaykul89
Contributor III

Thanks a lot Daniel. 

0 Kudos
Reply

2,159 Views
akshaykul89
Contributor III

Hello Daniel,

As I can understand the flow, above snippet (or similar logic) can be called from ISR. What value does "active" array signifies ? and same question is for vector_active.

I tried to have this snippet integrated in my sample code. There are two interrupts enabled to bring MCU from VLPS to RUN such as , ADC0 interrupt and Port C button interrupt. This test is driven on S32K144 EVB.

I am not able to understand significance of these values with respect to corresponding interrupt. 

for ADC

pastedImage_1.png

For Port C button interrupt,

pastedImage_2.png

How should I extract from these values , which interrupt is this?

Interrupt Active bit Register holds S32_NVIC_IABR_COUNT [i.e. 8 ] values. This might very basic question to ask but I would really appreciate your inputs on this. Thanks a lot for understanding. 

Regards,

Akshay K.

0 Kudos
Reply

2,159 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Akshay,

IABR[1] = 128 = 0x80 = (1 << 7)

39 % 32 = 7

You should see vector_active = 55.

pastedImage_8.png

pastedImage_9.png

Similarly for the PORTC interrupt

IABR[1] = 536870912 = 0x20000000 = (1 << 29)

61 % 32 = 29

vector_active = 77.

pastedImage_11.png

Regards,

Daniel

2,159 Views
akshaykul89
Contributor III

Thanks a lot Daniel. I really appreciate your quick response.

Could you please share the link of this document ? This will be helpful for me in future.

Regards,

Akshay K.

0 Kudos
Reply

2,159 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Akshay,

the document is attached to the reference manual:

pastedImage_1.png

BR,

Daniel

2,159 Views
akshaykul89
Contributor III

Thanks Daniel, the RM document available on NXP site does not show it for Cortex M4 but for Cortex M0+.

https://www.nxp.com/docs/en/reference-manual/S32K-RM.pdf 

Can you please share URL of S32K-RM for Cortex-M4 ? Cortex-M0+ has just Vector (0-47).

Regards,

Akshay K.

0 Kudos
Reply

2,159 Views
danielmartynek
NXP TechSupport
NXP TechSupport

This is the RM.

You should be able to find this in the S32K1xx_DMA_Insterrupt_mapping.xlsx file

pastedImage_1.png

Can you show me what you see, a screenshot?

Thanks, 

Daniel

0 Kudos
Reply

2,159 Views
akshaykul89
Contributor III

Hello Daniel,

Problem solved. I was referring false data. Thank you.

Regards,

Akshay K.

0 Kudos
Reply