This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

NMI implementation issue

I have written the NMI handler for the LPC1768 MCU based target board as below and I am using Keil MDK Lite v4.5. The CPU control enters the NMI handler when invoked by a logic High signal injected to P2.10 but, the issue is upon exit the CPU control loops in the HardFault_Handler implemented in the startup_LPC17xx.s file. Stack memory is set for 100 bytes. Also,is it possible to simulate NMI implementation in Keil MDK v4.5, i have tried it but no success.

void NMI_Handler (void){
LPC_GPIO1->FIOPIN |= (1<<29);
delay();
LPC_GPIO1->FIOPIN &= ~(1<<29);
}

int main (){
//Configuring GPIO P1.29 as Output to which an LED is interfaced
LPC_PINCON->PINSEL3 &= ~((1<<27)|(1<<26));
LPC_GPIO1->FIODIR |= (1<<29);
LPC_GPIO1->FIOPIN &= ~(1<<29);

//Configuring P2.10 as NMI pin
LPC_PINCON->PINSEL4 &= ~(1<<20);
LPC_PINCON->PINSEL4 |= (1<<21);

//Enable NMI
NVIC_EnableIRQ(NonMaskableInt_IRQn);

while(1);
}

Parents
  • You have Hard Fault. NMI priority is higher then Hard Fault priority and this is why you have Hard Fault only after NMI. Look like something happens in your delay function. Try comment code inside NMI_Handler and see what happens.

    void NMI_Handler (void){
    //LPC_GPIO1->FIOPIN |= (1<<29);
    //delay();
    //LPC_GPIO1->FIOPIN &= ~(1<<29);
    }

    Also, even if you have Hard Fault exception you should still have NMI working. NMI is HIGHER priority (except Reset).

Reply
  • You have Hard Fault. NMI priority is higher then Hard Fault priority and this is why you have Hard Fault only after NMI. Look like something happens in your delay function. Try comment code inside NMI_Handler and see what happens.

    void NMI_Handler (void){
    //LPC_GPIO1->FIOPIN |= (1<<29);
    //delay();
    //LPC_GPIO1->FIOPIN &= ~(1<<29);
    }

    Also, even if you have Hard Fault exception you should still have NMI working. NMI is HIGHER priority (except Reset).

Children