AnsweredAssumed Answered

HAL_ADC_DeInit sets the WRPERR bit in FLASH->SR register!

Question asked by bernabeu.Anthony on Jun 8, 2016
Latest reply on Jun 10, 2016 by bernabeu.Anthony
Hi All,

I encounter some issues with writing to eeprom on a STM32L152RET6. 
I followed the PM0062Programming manual and  if I just run my code to write to eeprom it is working fine. However, I need to run an ADC conversion. I have used cubeMx to generate the code. So In my main I have a function call to MX_ADC_Init(); which will call: 
if (HAL_ADC_DeInit(&hadc) != HAL_OK)
By doing step debugging, I can see that when I call HAL_ADC_DeInit the WRPERR bit is set in FLASH->SR.
This particular line is a problem: __HAL_ADC_CLEAR_FLAG(hadc, (ADC_FLAG_AWD | ADC_FLAG_JEOC | ADC_FLAG_EOC |
                                ADC_FLAG_JSTRT | ADC_FLAG_STRT));


I even used the STM32Cube_FW_L1_V1.5.0\Projects\STM32L152RE-Nucleo\Examples\FLASH\FLASH_WriteProtection
project and just added ADC and I can see the same issue there (just wanted to be sure that I did have anything wrong in my code somewhere else).

Anyone already seen this kind of problem? 

I tried to clear the flag by calling: __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_WRPERR);

and it works but not sure if this is a good way of doing things.

Thanks for your help. stm

B.

Outcomes