AnsweredAssumed Answered

flash readback protection

Question asked by apel.yaron on Nov 30, 2015
Latest reply on Dec 9, 2015 by Clive One
Hi

I am trying to enable flash read protection (level 1) on STM32L151 chip.

I use this code section, at the beggining of my program:

 FLASH_Status FLASHStatus = FLASH_COMPLETE;
 
 /* Unlock the Flash Program Erase controller */
 FLASH_Unlock();
 
 FLASH_OB_Unlock();
 
 if (!FLASH_OB_GetRDP())
 {
   FLASHStatus = FLASH_OB_RDPConfig(OB_RDP_Level_1); 
 
    if (FLASHStatus == FLASH_COMPLETE)
    {
      /* Generate System Reset to load the new option byte values */
      FLASH_OB_Launch();
    }
  } 


I am able to set the read protection (I know that becuase after I cannot connect to the chip via the debugger).
the problem is that after I enable read protection, my code doesn't run anymore... (I verify this using led toggle).
I have tried setting read protection  also using STM32 ST-LINK utility, with same results.
I am using STM32 ST-LINK utility to set back read protection to level 0, and than I can connect via debugger again.

Any ideas what I am doing wrong? how can I debug this issue?

Many thanks
Yaron

Outcomes