STM32F0xx read protection enable

General discussion on mikroBasic PRO for ARM.
Post Reply
Author
Message
jodybotha@yahoo.ca
Posts: 11
Joined: 09 Feb 2014 20:49

STM32F0xx read protection enable

#1 Post by jodybotha@yahoo.ca » 10 Jul 2019 20:16

Good Day,

Please could someone help me ????

I am struggling to get the read protection activated on stm32f0xx device

the major issue I am having is trying to declare the option byte address byte as I keep getting
an error "Bad Address xxxxxx" after adding the declaration in the declaration page

xxxxxx as longword absolute 0x1FFFF800 volatile ccm

I have tried using the following with the same error message result

xxxxxx as longword absolute 0x1FFFF800 volatile rx
xxxxxx as longword absolute 0x1FFFF800 volatile sfr
xxxxxx as longword absolute 0x1FFFF800 volatile data
xxxxxx as longword absolute 0x1FFFF800 volatile code
xxxxxx as longword absolute 0x1FFFF800 volatile org

I am willing to share my complete code once it works !!!!!!

sub procedure Lockmychip() 'enable read protection for STM32F030F'
dim pass as byte
pass = 1

'Note: When readout protection is set for the first time,
' the chip must be powered off and on again before it will work again.

if FLASH_OBR.B1 = 0 then 'check if the read protection is enabled, if not enable the routine
pass = 0
end if

if pass = 0 then 'this mean the device has not been read protected yet and it goes into the routine
while (FLASH_SR.BSY) 'wait for flash to finish
wend
'unlock option bytes
FLASH_OPTKEYR = 0x45670123 'Use the keys to unlock the flash (Security gate)
FLASH_OPTKEYR = 0xCDEF89AB 'Use the key to unlock the flash (then the door)

FLASH_CR.OPTWRE = 1 'enable option byte write
FLASH_CR.OPTPG = 1
'set read protection in the option byte register (0x1FFFF800) to 0x00FF55BB from 0x00FF55AA (Declared in module)
xxxxxx = 0xBB
FLASH_OBR.B1 = 1
'write to flash register to enable the changes
FLASH_CR.B13 = 1
'Wait for the process to complete
while (FLASH_SR.BSY)
wend
'Lock the Flash
FLASH_CR.B7 = 0
end if
end sub

please please please can anyone help?

Best regards
Jody

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: STM32F0xx read protection enable

#2 Post by filip.grujcic » 23 Jul 2019 08:26

Hi,

I believe I answered you on the ticket you opened.
If you need any further assistance, you can contact me there.

Kind regards,
Filip Grujcic

Post Reply

Return to “mikroBasic PRO for ARM General”