K22 Brown Out and Recovery

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

K22 Brown Out and Recovery

Jump to solution
1,239 Views
burgeh
Contributor IV

Greetings,

I am using a K22FN256LH12 with KDS v3.2 with processor expert.

I am wondering what components or solutions are available for K22 brown/black out recovery. I currently I have it being powered by battery and when the battery is charged to the voltage threshold, I would like to control (or have an event be triggered) or know where it goes. What are my options?

Thanks!

1 Solution
928 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Christopher,

   The POR is automatically controlled by the MCU, the LVD can provide the falling voltage threshold and trigger a interrupt.

   About the POR information, please associate the reference manual and the datasheet:

pastedImage_1.png

pastedImage_2.png

So, if you just want to use the POR to detect the VDD,this is controlled by the MCU automatically, you don't need to use the PE component, even you want to use the LVD to detect the falling voltage threshold, you can use the PMC module register to control it directly.

Wish it helps you!

If you still have question about it, please kindly let me know.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

2 Replies
929 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Christopher,

   The POR is automatically controlled by the MCU, the LVD can provide the falling voltage threshold and trigger a interrupt.

   About the POR information, please associate the reference manual and the datasheet:

pastedImage_1.png

pastedImage_2.png

So, if you just want to use the POR to detect the VDD,this is controlled by the MCU automatically, you don't need to use the PE component, even you want to use the LVD to detect the falling voltage threshold, you can use the PMC module register to control it directly.

Wish it helps you!

If you still have question about it, please kindly let me know.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

928 Views
mjbcswitzerland
Specialist V

Hi

Here is a reference from the uTasker project.

1. The user can choose to have a user interrupt callback on low of power warning by defining SUPPORT_LOW_VOLTAGE_DETECTION

2. When this is defined the user supplies a callback handler (default is the following):

// Power failure user interrupt callback that can be used to save critical work
//
extern __callback_interrupt int fnPowerFailureWarning(void)
{
    fnDebugMsg("Power failing!!\r\n");
    return 0;                                                            // don't re-enable detection interrupt since in the case of power loss it will continue to fire
}
‍‍‍‍‍‍‍

3. The user also chooses the threshold voltage (typical values are - 1.8V, 1.9V, 2.1V, 2.1V, 2.7V, 2.8V, 2.9V or 3.0V) by defining it with
#define LOW_VOLTAGE_DETECTION_VOLTAGE_mV       2900                  // 2.9V warning threshold

and the closest reset thresholds and warning thresholds are set using

    #if !defined LOW_VOLTAGE_DETECTION_VOLTAGE_mV                        // if no value is defined we delault to 2.10V warning threshold and 1.6V reset threshold
        #define LOW_VOLTAGE_DETECTION_VOLTAGE_mV   2100
    #endif
    fnEnterInterrupt(irq_LOW_VOLTAGE_ID, 0, _low_voltage_irq);           // enter highest priority interrupt to warn of failing voltage
    #if LOW_VOLTAGE_DETECTION_VOLTAGE_mV > 2400                          // sensitive detection level
    // K64 reference: high reset threshold is typically 2.56V
    //
    PMC_LVDSC1 = (PMC_LVDSC1_LVDV | PMC_LVDSC1_LVDRE | PMC_LVDSC1_LVDACK); // high voltage level trip with reset enabled (clear flag)
        #if LOW_VOLTAGE_DETECTION_VOLTAGE_mV >= 3000
    PMC_LVDSC2 = (PMC_LVDSC2_LVWV_HIGH | PMC_LVDSC2_LVWIE | PMC_LVDSC2_LVWACK); // enable low voltage warning interrupt (clear flag) 3.00V typical
        #elif LOW_VOLTAGE_DETECTION_VOLTAGE_mV >= 2950
    PMC_LVDSC2 = (PMC_LVDSC2_LVWV_MID2 | PMC_LVDSC2_LVWIE | PMC_LVDSC2_LVWACK); // enable low voltage warning interrupt (clear flag) 2.90V typical
        #elif LOW_VOLTAGE_DETECTION_VOLTAGE_mV >= 2850
    PMC_LVDSC2 = (PMC_LVDSC2_LVWV_MID1 | PMC_LVDSC2_LVWIE | PMC_LVDSC2_LVWACK); // enable low voltage warning interrupt (clear flag) 2.80V typical
        #else
    PMC_LVDSC2 = (PMC_LVDSC2_LVWV_LOW | PMC_LVDSC2_LVWIE | PMC_LVDSC2_LVWACK); // enable low voltage warning interrupt (clear flag) 2.70V typical
        #endif
    #else
    // K64 reference: low reset threshold is typically 1.6V
    //
    PMC_LVDSC1 = (PMC_LVDSC1_LVDRE | PMC_LVDSC1_LVDACK);                 // low voltage level trip with reset enabled (clear flag)
        #if LOW_VOLTAGE_DETECTION_VOLTAGE_mV > 2050
    PMC_LVDSC2 = (PMC_LVDSC2_LVWV_HIGH | PMC_LVDSC2_LVWIE | PMC_LVDSC2_LVWACK); // enable low voltage warning interrupt (clear flag) 2.10V typical
        #elif LOW_VOLTAGE_DETECTION_VOLTAGE_mV >= 1950
    PMC_LVDSC2 = (PMC_LVDSC2_LVWV_MID2 | PMC_LVDSC2_LVWIE | PMC_LVDSC2_LVWACK); // enable low voltage warning interrupt (clear flag) 2.00V typical
        #elif LOW_VOLTAGE_DETECTION_VOLTAGE_mV >= 1850
    PMC_LVDSC2 = (PMC_LVDSC2_LVWV_MID1 | PMC_LVDSC2_LVWIE | PMC_LVDSC2_LVWACK); // enable low voltage warning interrupt (clear flag) 1.90V typical
        #else
    PMC_LVDSC2 = (PMC_LVDSC2_LVWV_LOW | PMC_LVDSC2_LVWIE | PMC_LVDSC2_LVWACK); // enable low voltage warning interrupt (clear flag) 1.80V typical
        #endif
    #endif
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

4. The general interrupt performs

// Interrupt to warn that the voltage is close to the reset threshold
// - the interrupt is disabled since in the case of power loss in progress it will not be possible to clear the interrupt flag
// - the user callback can request the interrupt to be re-enabled and a clear be attempted by returing a non-zero value if it is prepared to handle multiple interrupts
//
static __interrupt void _low_voltage_irq(void)
{
    PMC_LVDSC2 &= ~(PMC_LVDSC2_LVWIE);                                   // disable further interrupts so that the processor can continue operation (it can decide to re-enable interrupts if desired)
    if (fnPowerFailureWarning() != 0) {                                  // user supplied routine to handle power faiure (interrupt call back)
        OR_ONE_TO_CLEAR(PMC_LVDSC2, (PMC_LVDSC2_LVWACK));                // acknowledge the interrupt and attempt to clear the flag (in the case of power loss in progress this will never be able to clear the flag)
        PMC_LVDSC2 |= (PMC_LVDSC2);                                      // re-enable the interrupt
    }
}
‍‍‍‍‍‍‍‍‍‍‍‍

The commenting in the code should explain all technical details.

Regards

Mark

uTasker - for more performance and faster, cheaper product development

0 Kudos