2019-07-04 05:31 AM
I've got a real strange error, and I really don't understand it.
I'm using a STM32F407VET6 Microcontroller. I also use CubeMX to generate the configurations.
But especially with the Timers, it's not possible to set every setting I need with Cube, so I added a custom timer init function for this. I'm using Timer 6, Timer 7 and Timer 13.
Additionally I use one Sector of the Flash as EEPROM. But since I added my custom Timer functions, the EEPROM erasing and writing isn't working anymore. I found out, that the Bits PGPERR and PGSERR in the Flash->SR register are set. But the strange thing is, the Bits are set after my Tming configuration function!
This is my configuration function:
TIM7->CR1 |= TIM_CR1_URS;
TIM7->DIER |= TIM_DIER_UIE;
TIM6->DIER |= TIM_DIER_UIE;
TIM13->CR1 |= TIM_CR1_URS;
TIM13->DIER |= TIM_DIER_UIE;
When I only configure one of the Timers, then the Flash Error bits are not set. And it's not matter which Timer, so long it's only one.
I also can configure Tim7 and Tim13 together, this gives also no Error Bits. But every combination with Tim6 causes the Error. But Tim6 alone is working.
The Erata Sheet has nothing about this.
Any ideas?
Thanks
2019-07-04 06:03 AM
Doesn't look to configure much of anything. You service the interrupts properly? You clear the errors? You run without the debugger?
2019-07-04 08:32 AM
Additional questions:
2019-07-04 10:41 PM
Thank you for your answers.
@Community member
At this moment, the timer interrupts are not enabled. Only configured. I start the timers later in my application, but the flags in the register are set at the configuration. So far I didn't cleared the errors in the Flash register, but I try this next. I tested with and without debugger. I added a if() after every timer config and toggled a Pin. It doesn't matter if I use the debugger or not, the Error Flags are Set at the same position.
@Alex R
I also wrote an own Bootloader. This is placed in the first Sector of the Flash. In the 2nd Sector is my EEPROM. After that follows the User Code. My Bootloader is using the same HAL Functions for accessing the Flash (Erase and Programming) and works fine. A few months ago I implemented something similar with a F1 Microcontroller. There I'm using a 2kB page for the EEPROM and this works also fine with the HAL functions.
2019-07-05 12:58 AM
I think I found my mistake. The HAL functions for initializing the timers are causing a update/interrupt of the timer. So after I was setting the Enable Interrupt Bit (TIM_DIER_UIE), the interrupt is executed immediately. But at this moment, one pointer in my ISR is not correct initialized and is showing somewhere in the Flash. And this causes the Error in the Flash Register. Clearing the Update Interrupt Flag in the SR Register of the Timers before setting the Enable Interrupt Flag solves the problem so far.