Microcontroller stops responding after accessing registers of uninitialized peripheral

Viewed 41

I am working on ARM cortex M3 processor. After accessing MCPWM register controller stops responding in which no interrupts will work. Intentionally I have not initialise MCPWM. So i wanted to know, where actually code flow(Program counter) goes, reason of controller hang.

2 Answers

Does MCPWM == Motor Control Pulse Width Modulation register? If so, I don't think ARM cortex-m3 provides any such system register. Most probably, such a register is provided by the chip vendor. From the internet, it seems ESP32 has such a register.

One will have to look at the datasheet, to find out as to what happens on uninitialized access to such a register. My educated guess tells me it might lead to a fault of some type. Since your observation is that the controller goes to a hang with interrupts not working, it might have led to a Hard or Usage fault.

Most chip vendors, have a busy loop when a Hard/Usage fault occurs. If you have a debugger available, you can try attaching it and see what the contents of below registers are when the issue arises. 1: Configruable Fault Status Register (For Usage Fault) 2: Hard Fault Status Register (HFSR)

If you have access to the complete source code or symbol, you can also try connecting the device via gdb and try to break where the source code is halting. It will probably be in a fault handler.

Thanks for reply..

I am using LPC17xx series.

{    
LPC_SC->PCONP |= 0x00020000;             
LPC_PINCON->PINSEL3 |= (0x01<<18)| 
(0x01<<24);
LPC_MCPWM->TC2 = 0;
LPC_MCPWM->LIM2 = 2048;
LPC_MCPWM->MAT2 = 1024;

  LPC_MCPWM->CON_SET = 1 << 17;
   LPC_MCPWM->CON_SET = 1 << 18;
   LPC_MCPWM->CON_CLR = 1 << 19;

   LPC_MCPWM->DT &= ~(0x3FF << 20);
  
   LPC_MCPWM->DT |= (channelSetup- 
   >channelDeadtimeValue & 0x3FF) << 20;


   LPC_MCPWM->CON_CLR = 1 << 20;
   NVIC_EnableIRQ(MCPWM_IRQn);

   LPC_MCPWM->INTEN_SET = 0x01 << 8;
}

This is part of the code which is used to initialize MCPWM But intentionally this code is commented and controller hang after executing below code which is used to stop MCPWM

{
    regVal |= (1 << 16);

    LPC_MCPWM->CON_CLR = regVal;

  }

I will buy debugger to monitor fault registers.

Related