2021-06-12 05:00 AM
2021-06-16 06:26 AM
Did you just pick random values to pass to HAL_FLASHEx_Erase and hope it would work?
Plenty of examples to go from
2021-06-12 05:47 AM
There are some predefined possibilities available with the PVD functionality.
For an arbitrary level, hook up an ADC to the supply (with resistor divider), or use the VBAT tap if VBAT=VDD, and use the ADC analog watchdog functionality.
2021-06-16 02:44 AM
I have the following:
/* USER CODE BEGIN 4 */
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
if (GPIO_Pin == WE_Pin) {
on = 1;
HAL_FLASH_Unlock();
// FLASH_Erase_Sector(FLASH_SECTOR_7, FLASH_VOLTAGE_RANGE_3);
HAL_FLASHEx_Erase(FLASH_SECTOR_7, FLASH_VOLTAGE_RANGE_3);
HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, FLASH_SECTOR_7, 400);
HAL_FLASH_Lock();
set_time = *(__uint32_t*) FLASH_SECTOR_7;
}
}
/* USER CODE END 4 */
Why is it crashing on deleting FLASH?
greetings
Andrzej
2021-06-16 06:26 AM
Did you just pick random values to pass to HAL_FLASHEx_Erase and hope it would work?
Plenty of examples to go from
2021-06-16 08:07 AM
And apparently compiler warnings are also for kids, not "the real guys"...
2021-07-05 09:03 AM
1. I interrupted lowering the PVD below 3.0. Works.
2. I have set FLASH_EraseInitTypeDef EraseInitStruct;
void FLASH_Erase(void) {
EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
EraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3;
EraseInitStruct.Sector = FLASH_SECTOR_7;
EraseInitStruct.NbSectors = 1;
HAL_FLASH_Unlock();
if (HAL_FLASHEx_Erase(&EraseInitStruct, &SECTORError) != HAL_OK)
;
}
3. I have inserted a FLASH record into the interrupt
void HAL_PWR_PVDCallback(void) {
HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, FLASH_SECTOR_7, total_time);
HAL_FLASH_Lock();
}
4. Builds without error
5. I have concerns about entering the program into DISCOVERY because I blocked the contact between DISCOVERY and Laptop when I entered it earlier.
6. is this program correct?
Other problem:
1. FLASH_SECTOR_7 has the address 0x08C0 0000
2. The IDE reads FFFF FFFF at this address
3. There should be a variable uint32_t total_time at this address
4. In Live Expression I read 4101158945 and not FFFF FFFF
5. These are different values. Why?
greetings
Andrzej