Hi,
I am trying to put KL05 to VLLS1 mode. I have configured LLW_P6 /PTB4 to wake up in falling edge.
My problem is, the microcontroller is going to VLLS1 mode. But It is not waking up when I change the state of LLW_P6/PTB4 to low.
/************************************************************ This is my code *************************************************************************/
#include "derivative.h" /* include peripheral declarations */
#include "SpiComm.h"
#include "dma.h"
#include "timer.h"
#include "globals.h"
#define SET_NMI_INTERRUPT() SCB_ICSR |= SCB_ICSR_NMIPENDSET_MASK
#define PORTB_TOGGLE(n) GPIOB_PTOR = 0x0001 << (n)
#define PORTB_SET(n) GPIOB_PSOR = 0x0001 << (n)
#define PORTB_CLR(n) GPIOB_PCOR = 0x0001 << (n)
#define PORTB(n) GPIOB_PDIR & (0x01 << (n))
void InitPortB(){
SIM_BASE_PTR->SCGC5 |= 0x01 << 10; // Enable clock
PTB_BASE_PTR ->PDDR |= 0x01 << 8; // Direction : Output
PTB_BASE_PTR->PDOR = 0x01; // Initial value = 0
PORTB_BASE_PTR->PCR[8] = 0x01 << 8; // Enable MUX
PTB_BASE_PTR->PDDR &= ~(0x01 << 4); // PTB4 as input
PORTB_BASE_PTR->PCR[4] |= 0x01 << 8; // Enable MUX for PTB4
PORTB_BASE_PTR->PCR[4] |= 0x01 << 1; // Enable Pull-up/Pull-down
PORTB_BASE_PTR->PCR[4] |= 0x01 << 0; // Enable Pull-up resistor
// PORTB_BASE_PTR->PCR[4] |= 0x08 << 16; // Interrupt when logic '1'
// NVIC_BASE_PTR->ISER |= (uint32_t)(0x01 << 31);
}
void InitPortA(){
GPIOA_PDDR &= ~(0x1000);
PORTA_PCR12 &= ~(0x01 << 8);
PORTA_PCR12 |= 0x01 << 8;
PORTA_PCR12 |= 0xB0000;
((NVIC_MemMapPtr)0xE000E100)->ISER |=0x01<<30;
}
void Set_VLLS1(){
uint8_t temp1 = 0;
// Configure VLLS Mode
SMC_PMPROT = 0x02; // Allow Low Leakage Power Modes (VLPR,VLPW,VLPS,LLS)
temp1 = SMC_PMPROT; // Dummy read
SMC_PMCTRL = 0x04; // Run and Stop Mode Control (RUN,VLPR,VLPS,LLS,VLLSx)
temp1 = SMC_PMCTRL; // Dummy read
SMC_STOPCTRL = 0x01; // Select VLLS1
// Configure Wakeup source
LLWU_PE2 = 0x20; // Enable LLW_P6/PTB4 as wakeup source (Falling edge)
LLWU_ME = 0x40; // Enable LLWU Module 6
LLWU_F1 |= 0x01 << 6;
LLWU_F3 |= 0x01 << 6;
}
int main(void)
{
unsigned int count1 = 0x00;
InitPortB();
TimerInit();
SPI_Init(); //
Set_VLLS1(); // Configure sleep mode
PORTB_SET(8);
for(count1=0; count1<128; count1++){
SpiBuff[count1] = 0x0A + count1;
}
while(1){
if(TimeCount == 500){ // If count reached
TimeCount = 0; // Clear count
SCB_SCR|=SCB_SCR_SLEEPDEEP_MASK; // Enable ARM deep sleep modes
__asm("WFI"); // Go to sleep
}
if(PORTB(4)){
asm("nop");
}
}
return 0;
}
Did I miss something or did I do something wrong??
Please help me guys..
Thanks and regards
Varun Rajarangan