cancel
Showing results for 
Search instead for 
Did you mean: 

HAL, STM32F746GDISCOVERY, STM32CubeIDE

ADębs.1
Senior

How to generate a break when the supply voltage drops below a certain value in the HAL?

Andrzej

1 ACCEPTED SOLUTION

Accepted Solutions

Generally one would pre-erase a sector, and then journal across it.

How long exactly is it taking now?

Is there some RTC, BKP or NVRAM you can use instead? Perhaps save data there, and go into STANDBY, save the FLASH when power restored.

Perhaps you can immediately gear-down to a slower clock to save power?

Have code in the IRQ Handler directly, and disable all other IRQs?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

9 REPLIES 9
TDK
Guru

If the answers to your previous posts on this topic were insufficient, please reply there with further details rather than creating another duplicate post with the same question.

https://community.st.com/s/question/0D53W00000sBTu0SAG/stm32f746gdisco-stm32cubeide-flash-supply-voltage-drop

https://community.st.com/s/question/0D53W00000uYj4KSAS/stm32f746gdiscovery-pwrpvd-stm32cubeide

If you feel a post has answered your question, please click "Accept as Solution".
SBEN .2
Senior II

Hello @Andrzej Dębski​ ,

If by generating a break you mean resetting the microcontroller, please check the Power Supply Supervisor section (2.4) of the Reference manual.

In this case you should use not HAL but LL (stm32h7xx_ll_pwr.c) to access the registers.

Best regards,

@SBEN .2​ 

I will follow the comments.

I am working on writing to a FLASH uint32_t variable, on power off. I am trying to do this using PVD. So far, no luck. I wrote to FLASH and blocked contact with the Discovery disc. Turning off the power and trying to connect to the programmer will not work.

Andrzej

I was able to program the break when the voltage dropped. I used the wrong instruction.

static void PVD_NVIC_Init(void) {

   PWR_PVDTypeDef sConfigPVD;

   sConfigPVD.PVDLevel = PWR_PVDLEVEL_6;

   sConfigPVD.Mode = PWR_PVD_MODE_IT_FALLING;

   HAL_PWR_ConfigPVD(&sConfigPVD);

   HAL_PWR_EnablePVD();

}

Without interruption.

Now I will try to write to FLASH. I will inform.

Best regards

Andrzej

Writing flash into a collapsing supply,​ probably a good way to brick things.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I don't understand "brick". Please explain.. This is jargon?

regerds

Andrzej

I did the power-off memorization as shown. HAL_PWR_PVD and HAL_FLASH_Program interrupt.

void HAL_PWR_PVDCallback(void) {
	if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, ADD_FLASH, total_time)
			== HAL_OK)
		HAL_FLASH_Lock();
}

Can you even speed up your programming?

Andrzej

Generally one would pre-erase a sector, and then journal across it.

How long exactly is it taking now?

Is there some RTC, BKP or NVRAM you can use instead? Perhaps save data there, and go into STANDBY, save the FLASH when power restored.

Perhaps you can immediately gear-down to a slower clock to save power?

Have code in the IRQ Handler directly, and disable all other IRQs?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I'll check how long it takes now. As a last resort, I will lower the clock. Obviously it works and I'm happy but I wonder if it wouldn't be enough.

Andrzej