10 years, 9 months ago.

How to determine reset source in KL46Z?

E.g., From external reset pin, power on reset (POR), timer, watchdog, etc. I looked for, but failed to find, source code referring to the Freescale RCM_RPFC reset register which has flag bits for the reset type. Also looked for RCM->POR or RCM->PIN. Has this been implemented in the Freescale ports? Thanks!

2 Answers

10 years, 9 months ago.

Hello K B,

I don't recall seeing any library which would use RCM registers to recover an application after reset. What exactly do you need?

Here's an example how RCM can be used, taken from TSS library:

        /* Read RCM for identification of Chip Reset reason */
        if (RCM->SRS0 & RCM_SRS0_WAKEUP_MASK) {
            /* Releases hold with ACKISO:  Only has an effect if recovering from VLLS1, VLLS2, or VLLS3
             if ACKISO is set you must clear ackiso before calling pll_init
             or pll init hangs waiting for OSC to initialize
             if osc enabled in low power modes - enable it first before ack
             if I/O needs to be maintained without glitches enable outputs and modules first before ack. */
          if (PMC->REGSC &  PMC_REGSC_ACKISO_MASK) {
              PMC->REGSC |= PMC_REGSC_ACKISO_MASK; /* Clear ACKISO bit */
              LLWU->ME &= ~LLWU_ME_WUME4_MASK; /* TSI LLWU Input Disable = LLWU_M4IF */
          }
        } else if (RCM->SRS0 & RCM_SRS0_LOC_MASK) {
            /* Loss of clock case */
        }

Accepted Answer

Martin, Following a reset, I'd like to take action based on what caused the reset. Especially if power on versus watchdog versus reset button. I appreciate the seemingly on-point code snippet, but I don't know the what/where of the "TSS library?" Can you please direct me? Thanks!

posted by K B 13 Mar 2014

That was just a note that the code was taken from that libray. The TSS library, it's from Freescale, not available on mbed due licensing issues.

I found something better for you, User guide for Kinets (this document is for Kinetis V, but will be valid for kinetis L, at least what you need). There are user guides for each kinetis line, most probably kinetis L should contain same wake up section. You can find it on freescale webpage.

Refer to : http://cache.freescale.com/files/microcontrollers/doc/user_guide/KVQRUG.pdf Scroll to the section 5.4.2.5 Wake-up sequence, there are code snippets with explanation. Good starting point.

Regards,
0xc0170

posted by Martin Kojtal 13 Mar 2014
K B
poster
10 years, 9 months ago.

The KLQRUG.pdf document, which is for the Freescale KL processors, is where I originally found the references to the RCM register and reset flags. What had me stymied, was how to use them in the mbed environment. E.g., was there some library/structure, etc. for them.

Martin has encouraged me to use the same code for mbed and it works!

An example for power on reset check:

if (RCM->SRS0 & RCM_SRS0_POR_MASK) 
        porTrue = TRUE;
else
        porTrue = FALSE;  

The defines are already in MKL25Z4.h and MKL46Z4.h.

So, thanks very much Martin! -Keith