cancel
Showing results for 
Search instead for 
Did you mean: 

use PH3 pin as GPIO instead of BOOT0

Maunik Patel
Associate II
Posted on April 18, 2018 at 14:11

Hello all,

In STM32L432KB, I want to use PH3 pin as GPIO, instead of BOOT0 without affecting its boot sequence.

How should I achieve it ?
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on April 19, 2018 at 17:53

Hello Maunik,

nSWBOOT0 bit belongs to so called Option Bytes region of memory. It can be modified in two ways.

One solution is accessing correct address in Flash memory. You can do it by using HAL functions. Inside Cube L4 package installed on your hard drive you can find an example how to access Option Bytes. Please refer to this path:

...\STM32Cube_FW_L4_V1.10.0\Projects\STM32L476G_EVAL\Examples\FLASH\FLASH_WriteProtection

Oher solution is to use one of PC applications: ST-Link Utility or STM32Cube Programmer. Below I attach a picture, which shows Option Bytes with highlighted 

nSWBOOT0.

0690X0000060AgVQAU.png

Regards

Szymon

View solution in original post

7 REPLIES 7
Posted on April 18, 2018 at 16:41

>>

How should I achieve it ?

Have an external pull-down resistor to ensure behaviour at boot, and use the pin as an OUTPUT, or if an input that it will always be low at reset.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on April 19, 2018 at 00:42

Or clear the nSWBOOT0 option bit. See chapter 2.6  Boot configuration  and  8.3.15  Using PH3 as GPIO in RM0394.

Although that technically *does* affect the boot sequence... Depending on what exactly you want to achieve.

JW

Posted on April 19, 2018 at 08:26

Hello waclawek.jan,

Thank you for your valuable time.

According to the table Boot Modes in chapter 2.6 I found my current settings as below:

   - BOOT0 (pin PH3) = 0

   - nSWBOOT0 bit = 1

   - main flash empty = 0 (not sure about it as I don't know how to check it. But I'll manage it)

     (choosing Main Flash Memory as Boot area)

To replace it, my new settings would be:

   - nSWBOOT0 bit = 0

   - nBOOT0 bit = 1 (Main Flash Memory as Boot area)

Will you please tell me

the API for setting bits in FLASH_OPTR register

?

Somehow, I can't find it.

Thank You,

Maunik Patel
Posted on April 19, 2018 at 10:27

Sorry, I don't use the 'L43x.

JW

Posted on April 19, 2018 at 15:14

Hello waclawek.jan,

Thank you for the help.

I am reading more to find the way and will surely update here, if I find proper solution.

Regards,

Maunik Patel
Posted on April 19, 2018 at 17:53

Hello Maunik,

nSWBOOT0 bit belongs to so called Option Bytes region of memory. It can be modified in two ways.

One solution is accessing correct address in Flash memory. You can do it by using HAL functions. Inside Cube L4 package installed on your hard drive you can find an example how to access Option Bytes. Please refer to this path:

...\STM32Cube_FW_L4_V1.10.0\Projects\STM32L476G_EVAL\Examples\FLASH\FLASH_WriteProtection

Oher solution is to use one of PC applications: ST-Link Utility or STM32Cube Programmer. Below I attach a picture, which shows Option Bytes with highlighted 

nSWBOOT0.

0690X0000060AgVQAU.png

Regards

Szymon

Posted on April 20, 2018 at 14:00

Hello 

Szymon,

You made my day.

I used the 2nd option (using

STM32Cube Programmer

) and it just worked.

Thank you very much for the easily understandable help.

Though option one (programming the FLASH) is good for deep learners, it is quite lengthy and confusing for some one who doesn't know in detail about programming the FLASH.

So, I choose 2nd option, which takes no time to configure the Option Bytes. Its too easy to use.

Thanks again for the help...

Thanks a lot...

Regards,

Maunik Patel