LLWU external wake up

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

LLWU external wake up

1,511 Views
DarthVader
Contributor II

Hello,

 

I am facing a strange behaviour that maybe someone can comment.

I am using MK20DX256VLL7 in the 72Mhz tower board and CW 10.2 with the service pack in linux.

 

I am running the MCU using the RTC and the FLL at 72Mhz.

 

My app is a simple loop that stays all the time in LLS mode and  has 3 wake up sources:

 

The LPTMR to wake up the k20 mcu from LLS at most every 10ms, (this means that can be less for example 1ms then after 3ms etc..) but for sure that once every 10ms it wakes up. It is configured as a wake up module in the LLWU using LLWU_ME_WUME0_MASK.

 

Then the UART rx pin which maps to the LLWU_PE1_WUPE0.

 

and finally PTC5 configured as an external interrupt on rising edge

 

//ptc5 .. ptc5 is pin 62, irq Aenable_irq(RADIO_EXTERNAL_PORT_IRQ_NUM);//enable the irq.   PORTC_PCR5 = PORT_PCR_MUX(1);// -- PTC5 used as gpioGPIOC_PDDR &= ~1<<RADIO_ISR_PIN; //set as input ==0PORTC_PCR5 |= PORT_PCR_IRQC(0x09); //9 interrupt on raising edge. PORTC_PCR5 |= PORT_PCR_ISF_MASK; //clear any pending interrupt.

 

I configure LLWU as follow:

 /*0x0200|0x0001 == LLWU_PE3_WUPE9 is external isr and LLWU_PE1_WUPE0 is UART RX */    llwu_configure( 0x0200|0x0001, LLWU_PIN_RISING, LLWU_ME_WUME0_MASK);

 

the PTC5 isr is mapped in the interrupt vector at position 89, (105 -16) and interrupts are enabled in the NVIC

 

void external_port_c_isr(void) { debugpins_isr_set();  //reconfigure..  if ((PORTC_ISFR) & (EXTPORTC_ISR_MASK)) {    PORTC_PCR5 |= PORT_PCR_ISF_MASK;    //clear flag  PORTC_ISFR |= EXTPORTC_ISR_MASK; //clear isr flag  //some simple calculation }else{  while(1); }      debugpins_isr_clr();}

 

in the LLWU isr I have:

 LLWU_F1 = 0xFF;            // clear wakeup flags
 LLWU_F2 = 0xFF;            // clear wakeup flags LLWU_F3 = 0xFF;            // clear wakeup flags

 to clear the flags.

 

finally my applicaton is a simple loop that goes all the time to LLS:

 

while(1){    clk_monitor_0(OFF);//turn off clock monitors so the freq can be changed without causing a reset    PORTA_PCR2 |= PORT_PCR_PE_MASK | PORT_PCR_PS_MASK;//JTAG_TDO     enter_lls();   //enter_wait();    clk_monitor_0(ON);//enable it again.}

 

If instead of going to LLS i go to WAIT, when the external pin is set, it executes normally the external_port_c_isr function and all works perfectly. (as expected)

 

However, when I go to LLS, the LLWU_ISR is executed whenever the external_isr_pin is toggled (as expected) but then never jumps to external_port_c_isr function (WHY??).

 

In contrast, the LPTMR after LLWU_isr, jumps to LPTMR_isr as described by the manual. Why I face this two different behaviours in the same thing?

 

for sure I miss something...

 

thanks!

 

 

 

0 Kudos
5 Replies

791 Views
namfuak
Contributor III
I didn't understand what is external_isr_pin, but if you mean that when external pin is asserted, the MCU wakes up from LLS but the port ISR is not executed I have an explanation for you: The port logic is not active while in LLS mode and cannot generate a interrupt. When you wake up from LLS, check the LLWU wakeup flag that corresponds to the pin and if it is set, set the interrupt pending bit by writing to ISPR.
0 Kudos

791 Views
DarthVader
Contributor II

Hello,

thanks for your answer!

 

This partially solves the problem, it raises the port_c interrupt as I've set the ISPR in the NVIC, however in the port_c interrupt function I cannot know what gpio is the issuer of this interrupt because this does not set PORTC_PCR5[ISF] or what is the same PORTC_ISFR which keeps to 0. 

 

This is a minor problem if in port_c function mapped at the position 105 of the vector I handle only one external interrupt, however if PTC5 and PTC6 are different sources of interrupt I cannot differentiate who of them raised it.

 

Am I wrong?

 

thanks again!

 

0 Kudos

791 Views
namfuak
Contributor III
You are right. The ISF register is zero from the same reason (the interrupt wasn't generated by GPIO logic). There are two options: 1. Serve the external pin interrupt in LLWU ISR context 2. In LLWU ISR context set ISPR and serve the external pin interrupt in PORT ISR context In order to distinguish between GPIOs you need to check LLWU flags in both cases. I do not think more elegant solution exists. I personally use the second option, because I prefer to process GPIO interrupt according to interrupt priorities configured, no matter whether it happen in one of LL modes or not.
0 Kudos

791 Views
DarthVader
Contributor II

thanks! not bad at all. The second option seems the more elegant.

 

0 Kudos

791 Views
Nana
Contributor II

First of all put the code for the enter_lls function to see what you may do wrong, maybe u set difrent power mode in PMC register, second u must set deepsleep bit in the system control reg SCB_SCR  before enter in stop mode !

 

 

and second I don't understand a thing about what you want to do !! Be more precise !

0 Kudos