Low Voltage Detect

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Low Voltage Detect

跳至解决方案
2,016 次查看
naderkhamess
Contributor III

Hi There,

We have S32K146 & S32K148, we would like to make our customers aware when the supply voltage of our MCU is low or high.  

I have informed myself about LVD system in reference manual and I have some inquiries/problems and kindly I would like to ask for your support. 

 

1. when I provided our MCU supply voltage between V lvd threshold  2.7 and 3.0 volts, I read PMC_LVDSC1[LVDF] that its 1 when low-voltage event detected, and when I provided back above V lvd, I have read 0 again, so it was working as I expected. But is it possible that I can also configure this threshold ? for example to make it between 2.7 and 3.2 ? 

naderkhamess_0-1635335693978.png

 

2. Regarding Low Voltage Warning, I am always reading PMC_LVDSC2[LVWF] = 1 regardless of what supply voltage is provided, I tried to provide voltage of all values between 2.7 until 5 volts and it is always returning 1. 

according to S32K1xx Datasheet, the threshold level for V lvw is between 4.19 and 4.5. 

so why I am always getting 1 even though my internal supply is above the trip point? maybe i missed something?

I am also aware that I should acknowledge LVWACK so that I clear LVWF.

 

 

 

 

 

 

 

 

void lvd_check(void)
{
    if(PMC->LVDSC1 & PMC_LVDSC1_LVDF_MASK)
    {
        LED_GREEN_ON;
        PMC->LVDSC1 |= PMC_LVDSC1_LVDACK(1);  // ACK event, clear LVDF when the power supply returns above the trip point.
        send_error_code(LOW_VOLTAGE_DETECTED);
    }
    else{
        LED_GREEN_OFF;
    }
    
    if(PMC->LVDSC2 & PMC_LVDSC2_LVWF_MASK)
    {
        LED_RED_ON; 
        PMC->LVDSC2 |= PMC_LVDSC2_LVWACK(1);  // ACK event, clear LVWF when the power supply returns above the trip point.
        //send_error_code(HIGH_VOLTAGE_DETECTED);
    }
    else{
        LED_RED_OFF;
    }

}

 

 

 

 

 

 

 

 

 

3. I am fine with polling the LVDF at the moment, but I tried also activate the interrupt, I saw an example there from nxp support. https://community.nxp.com/t5/S32K/S32K146-Low-Voltage-Detect/m-p/1096703

 

 

 

 

 

 

 

 

INT_SYS_InstallHandler(LVD_LVW_IRQn, VLD_ISR, (isr_t *)0);
INT_SYS_EnableIRQ(LVD_LVW_IRQn);
PMC->LVDSC1 = PMC_LVDSC1_LVDIE(1) | PMC_LVDSC1_LVDRE(0);

void VLD_ISR(void)
{
	if(PMC->LVDSC1 & PMC_LVDSC1_LVDF_MASK)
	{
		PINS_DRV_WritePin(PTD, BLUE_LED, 1);  // LED ON
		PMC->LVDSC1 |= PMC_LVDSC1_LVDACK(1);  // ACK event, clear LVDF when the power supply returns above the trip point.
	}
	PINS_DRV_WritePin(PTD, BLUE_LED, 0);  // LED OFF
}

 

 

 

 

 

 

 

 

so my configuration was : No system resets on low voltage. Only request hardware interrupt when LVDF=1

so the interrupt is working and I am jumping to the isr, however, I am always staying the isr and not returning to application, why ? 

why the MCU is only jumping to the isr? 

I see when the when the power supply returns above the trip point. LVDF is cleared and program counter jumps back to application, but why as long as power supply is falling below trip point we will always stay in Isr?

 

4. If for example I activated PMC_LVDSC1[LVDRE], and now the power supply dropped below LVD trip voltage and reset was generated. After MCU wakes up, I can read System Reset Status Register -> LVD 

but it is described that it will be 1, if reset caused by LVD trip or HVD trip or POR. So this means i will not be able to know if it was POR or LVD ? or how will I distinguish them? please enlighten me. 

naderkhamess_1-1635338961147.png

 

Thanks.

Cheers,
Nader

 

0 项奖励
1 解答
1,950 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hello Nader,

I'm sorry for the late response.

 

1.

Unfortunately, it is not configurable.

2.

I will need to test it, it might take some time.

3.

This is expected, the interrupt will be asserted again as the flag cannot be cleared.

You could disable the interrupt within the ISR.

4.

The POR bit would be set if the VDD voltage dropped further below the V_POR level (typ. 1.6V).

If the voltage stays above V_POR during the reset sequence, only LVD is set.

 

Regards,

Daniel

 

 

 

在原帖中查看解决方案

4 回复数
1,946 次查看
naderkhamess
Contributor III

Ok thanks for the answers! 

Regards,

Nader

0 项奖励
1,966 次查看
naderkhamess
Contributor III

@danielmartynek 

Hello, Could someone please answer my questions?

0 项奖励
1,951 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hello Nader,

I'm sorry for the late response.

 

1.

Unfortunately, it is not configurable.

2.

I will need to test it, it might take some time.

3.

This is expected, the interrupt will be asserted again as the flag cannot be cleared.

You could disable the interrupt within the ISR.

4.

The POR bit would be set if the VDD voltage dropped further below the V_POR level (typ. 1.6V).

If the voltage stays above V_POR during the reset sequence, only LVD is set.

 

Regards,

Daniel

 

 

 

1,101 次查看
abdullah45
Contributor I

Hi There,

would you please explain the criteria to test LVD?

How can i able to change in Vdd to set LVDF flag?

0 项奖励