How to make the rising edge detection save when switching between run and LLStop modes?

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

How to make the rising edge detection save when switching between run and LLStop modes?

1,399 Views
martinvonasek
Contributor I

Using LLWU pins interrupts means to be still in a LLStop mode. In a run mode it doesn't work (LLWU speciality), so I have to detect it by another way (port detection or software scan). But what will happen, when I'm switching back to LLStop mode? At this moment I can't detect the rising edge by resources which are not functional under LLStop, and LLWU interrupt is not yet active. I see a system hazard in this situation. How should I solve this situation correctly??

Labels (1)
0 Kudos
8 Replies

1,045 Views
bobpaddock
Senior Contributor III

"Memory Barrier Instructions" may be relevant here, I'm not sure, from your description.  Using a queue might be a better solution than trying to predicted which clock cycle an asynchronous event is going to happen at.

http://infocenter.arm.com/help/topic/com.arm.doc.dai0321a/DAI0321A_programming_guide_memory_barriers...

0 Kudos

1,045 Views
philip_drake
NXP Employee
NXP Employee

Hello Martin,

I've tested this exact question on the bench and it has a good solution which guarantee detection of the edge.

The LLWU wakeup pins share functionality with digital input ports that have edge detection functionality. You must use input pins that share this functionality to have this guarantee.

To insure that no edge is missed you need to

1) enable the port PCR register edge detect interrupt for the port pin.

2) enable the LLWU edge enable register for the same input pin for LLS wakeup.

When the edge occurs in Run, WAIT, STOP, VLPR, VLPW, VLPS.  the port interrupt will fire.

If the edge occurs as the MCU transitions between RUN or VLPR in to LLS or VLLSx low power modes the port interrupt is still going to fire and abort the low power mode entry.

The MCU may report a STOPA stop abort flag depending upon the timing of the edge with respect to the mode entry. 

The CPU will execute the port interrupt function and ,in LLS entry, will return execution to the instruction following the WFI instruction.

I hope this helps.  

I'm updating AN4503 and will include a paragraph on this topic.  It's critical for some applications as you note.

Best Regards,

Philip Drake

1,045 Views
martinvonasek
Contributor I

Hello Mr. Drake,

  thank you for an official idea. I'm waiting for hardware changes now (no all LLWU pins has an interrupt function on their standard ports).

  But there is another questions. Is it possible to disable WFI instruction shortly before executing it? There is a possible scenario that the interrupt will be detected one clock before WFI instruction. Then the interrupt rutine will be called, but I don't want to continue in a executing WFI instruction after end of the interrupt rutine because I must execute part of the main code which can not be executed from the interrupt rutine. I simply want to skip the WFI. What can I do best in this situation?

Best Regards,

Martin Vonasek

0 Kudos

1,045 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Martin Vonasek,

     Thank you for your interest in our product  and your question in our community.

     Did you mean you can't detect the rising edge interrupt when the pin is configured as the LLWU pins and work in run mode? And if you use the port dectection or software scan to dectect the port interrupt, then when you enter into the LLS mode, you can't use the rising edge to wakeup the MCU to run mode?

     Could you tell me the full name of the chip which you are used?

     I think maybe your LLWU and PORT configuration has some problems, could you give me your code, I will help you to check it!

     Waiting for your reply!

Best regards

Jingjing

0 Kudos

1,045 Views
martinvonasek
Contributor I

I'm sorry, it was difficult to understand what was my meaning. Please, look at the point 15.1.2.3 ("Non-low leakage modes") in the "KL14 Sub-Family Reference Manual" (rev. 3). I can't use the LLWU in a run mode. How should I do a correct edge detection, which works over all MCU modes (from RUN to LLS) ? I'm afraid of an edge loss when I'm changing modes and methods of detection in a program code. Can you recommend me the safest way how to detect edges without loss.

0 Kudos

1,045 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Martin vonaasek,

     Sorry for my later reply!

     It is a bit strange for your code function, could you tell me why you use this, just detect the rising edge?

     If you enter into LLS, and you use the LLWU interrupt to detect the rising edge, your MCU will exit the LLS immediately.

     Could you tell me the influence if lose an edge when change from RUN to LLS, and your usage?

    Waiting for your reply!

Best regards,

Jingjing

0 Kudos

1,045 Views
martinvonasek
Contributor I

Dear Mr. Zhou,

     1) I have to use LLWU pins because I need the lowest possible current consumption (battery powered wireless system).

     2) There are 3 critical interrupts: positive edge from RF tranceiver, two signals from magnetic sensors, periodic low-power timer.

     3) The most critical are magnetic sensors which detects the state of a window in a building (security system).

In a many cases system is switching between LLS and RUN. Window detection must be safe during this!

Best Reagards

   Martin Vonasek

0 Kudos

1,045 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Martin Vonasek,

       I will help you ask our low power expert to check it , it may take some time, so please wait patiently.

       If the expert reply me , I will tell you as soon as possible.

Best Regards,

Jingjing

0 Kudos