Skip to main content
Maunik Patel
Associate III
April 18, 2018
Solved

use PH3 pin as GPIO instead of BOOT0

  • April 18, 2018
  • 2 replies
  • 3371 views
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 ?
    This topic has been closed for replies.
    Best answer by Szymon PANECKI
    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

    2 replies

    Tesla DeLorean
    Guru
    April 18, 2018
    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 VenmoUp vote any posts that you find helpful, it shows what's working..
    waclawek.jan
    Super User
    April 18, 2018
    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

    Maunik Patel
    Associate III
    April 19, 2018
    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
    waclawek.jan
    Super User
    April 19, 2018
    Posted on April 19, 2018 at 10:27

    Sorry, I don't use the 'L43x.

    JW