17 Tutorial 7 - Using the X-Cube-BLE1 software pack

STM32CubeF4 MCU package if it is not present in STM32Cube repository.

  1. Click Open project. The Oryx software components are displayed in the generated project (see Figure 685).

Figure 685. Generated project with third party pack components

image714

17 Tutorial 7 – Using the X-Cube-BLE1 software pack

This tutorial demonstrates how to achieve a functional project using the X-Cube-BLE1 software pack.

Below the prerequisites to run this tutorial:

  • Hardware: NUCLEO-L053R8, X-NUCLEO-IDB05A1 and mini-USB cable (see Figure 686)

  • Tools: STM32CubeMX, IDE (Atollic® or any other toolchain supported by STM32CubeMX)

  • Embedded software package: STM32CubeL0 (version 1.10.0 or higher), X-Cube-BLE1

1.1.0 (see Figure 687).

  • Mobile application (see Figure 688): STMicroelectronics BlueNRG application for iOS® or Android

image715

Figure 687. Embedded software packages

image716

image717

Proceed as follows to install and run the tutorial:

  1. Check STM32CubeMX Internet connection:

    1. Select the Help > Updater Settings menu to open the updater window.

    2. Verify in the Connection tab that the Internet connection is configured and up.

  2. Install the required embedded software packages (see Figure 689):

    1. Select the Help > Manage Embedded software packages menu to open the embedded software package manager window.

    2. Click the Refresh button to refresh the list with the latest available package versions.

    3. Select the STM32Cube MCU Package tab and check that the STM32CubeL0 firmware package version 1.10.0 or higher is installed (the checkbox must be green). Otherwise select the checkbox and click Install now.

    4. Select the STMicrolectronics tab and check that the X-Cube-BLE1 software pack version 1.0.0 is installed (checkbox must be green). Otherwise, select the checkbox and click Install now.

Figure 689. Installing Embedded software packages

image718

  1. Start a new project:

    1. Select New Project to open the new project window.

    2. Select the Board selector tab.

    3. Select Nucleo64 as board type and STM32L0 as MCU Series.

    4. Select the NUCLEO-L053R8 from the resulting board list (see Figure 690).

    5. Answer No when prompted to initialize all peripherals in their default mode (see Figure 691).

Figure 690. Starting a new project - selecting the NUCLEO-L053R8 board

image719

  1. Add X-Cube-BLE1 components to the project:

    1. Click Additional Software from Pinout & Configuration view to open the Additional Software component Selection window.

    2. Select the relevant components (see Figure 692)

The Application group comes with a list of applications: the C files implement the application loop, that is the Process() function. From the Application group, select the SensorDemo application.

Select the Controller and Utils components

Select the Basic variant for the HCI_TL component . The Basic variant provides the STMicroelectronics implementation of the HCI_TL API while the template option requires users to implement their own code.

Select the UserBoard variant as HCI_TL_INTERFACE component. Using the UserBoard option generates the <boardname>_bus.c file, that is nucleo_l053r8_bus.c for this tutorial, while the template option generates the custom_bus.c file and requires users to provide their own implementation.

Refer to the X-Cube-BLE1 pack documentation for more details on software components.

  1. Click OK to apply the selection to the project and close the window. The left panel Additional Software section is updated accordingly.

Figure 692. Selecting X-Cube-BLE1 components

image720

  1. Enable peripherals and GPIOs from the Pinout tab (see Figure 693):

    1. Configure USART2 in Asynchronous mode.

    2. Configure SPI1 in Full-duplex master mode.

    3. Left-click the following pins and configure them for the required GPIO settings:

PA0: GPIO_EXTI0

PA1: GPIO_Output

PA8: GPIO_Output

  1. Enable Debug Serial Wire under SYS peripheral.

Figure 693. Configuring peripherals and GPIOs

image721

  1. Configure the peripherals from the Configuration tab:

    1. Click the NVIC button under the System section to open the NVIC configuration window. Enable EXTI line 0 and line 1 interrupts and click OK (see Figure 694).

    2. Click the SPI button under the Connectivity section to open the SPI configuration window. Check that the data size is set to 8 bits and the prescaler value to 16 so that HCLK divided by the prescaler value is less or equal to 8 MHz.

    3. Click USART2 under the Connectivity section to open the Configuration window and check the following parameter settings:

Under Parameter Settings:

Baud rate: 115200 bits/s

Word length: 8 bits (including parity) Parity: none

Stop bits: 1

Under GPIO Settings:

User labels: USART_TX and USART_RX

Figure 694. Configuring NVIC interrupts

image722

  1. Enable and configure X-Cube-BLE1 pack components from the Pinout & Configuration view:

    1. Click the pack items from the left panel to show the mode and configuration tabs.

    2. Click the check boxes from the Mode panel to enable X-Cube-BLE1, the configuration panel appears showing the parameters to configure. An orange triangle indicates that some parameters are not configured. It turns into a green check mark once all parameters are correctly configured (see Figure 695).

    3. Leave the Parameter Settings Tab unchanged.

    4. Go the Platform settings tab, configure the connection with the hardware resources as indicated in Figure 695 and Table 29.

Table 29. Connection with hardware resources


Name

IPs or components

Found solutions

BUS IO driver

SPI in Full-duplex master mode

SPI1

EXTI Line

GPIO:EXTI

PA0

CS Line

GPIO:output

PA1

Reset Line

GPIO:output

PA8

BSP LED

GPIO:output

PA5

BSP Button

GPIO:EXTI

PC13

BSP USART

USART in Asynchronous mode

USART2

Check that the icon turns to image723 . Click OK to close the Configuration window .

Figure 695. Enabling X-Cube-BLE1

image724

  1. Generate the SensorDemo project:

  1. Click image725 to generate the code. The Project Settings window opens if the project has not yet been saved.

  2. Click image726 to generate the code once the project settings have

been properly configured (see Figure 696). When the generation is complete, a dialog window requests to open the project folder (Open Folder) or to open the project in IDE toolchain (Open Project). Select Open Project (see Figure 697).

Figure 696. Configuring the SensorDemo project

image727

18 Creating LPBAM projects

18.1 LPBAM overview

Disclaimer: to learn about the LPBAM mode and its usage, it is recommended to read the LPBAM application note available on www.st.com, and the LPBAM utility getting started guide located under the Utilities folder of the STM32Cube firmware package.

LPBAM stands for low power background autonomous mode. It is an operating mode that allows peripherals to be functional and autonomous independently from power modes and without any software running. It is performed thanks to a hardware subsystem embedded in STM32 products. Thanks to DMA transfers in Linked-list mode, the LPBAM subsystem can chain different actions to build a useful functionality (peripheral configurations and transfers). Optionally, it can generate asynchronous events and interrupts. It operates without any CPU intervention. Consequently, the two major benefits from using the LPBAM subsystem mechanisms are an optimized power consumption, and an offloaded CPU.

The LPBAM firmware has been designed to help users create LPBAM applications: the LPBAM utility is a set of modular drivers located under the Utilities folder of the STM32Cube firmware package. Each module comes as a pair of C file that provides the APIs needed to build an application scenario. Each module manages the configurability and the data transfers for a given peripheral. The LPBAM utility is designed to be compatible with any STM32 devices supporting LPBAM subsystem mechanisms through a configuration module: it requires a configuration file stm32_lpbam_conf.h aligned with the application needs. The LPBAM utility has a single application entry point, the stm32_lpbam.h, that must be included in the project.

The LPBAM firmware supports STM32U575/585, STM32U595/5A5 and STM32U599/5A9 products, for projects with or without TrustZone activated.

STM32CubeMX 6.5.0 introduces LPBAM for projects without TrustZone activated on the

STM32U575/585 product line: users can create LPBAM applications for their project using STM32CubeMX LPBAM Scenario & Configuration view and generate the corresponding code. The generated C project embeds the LPBAM firmware.

STM32CubeMX 6.6.0 adds LPBAM support for projects with TrustZone activated.

It is recommended to use LPBAM to save power and offload the CPU.

  • The LPBAM mechanism supports the following set of peripherals on the Smart Run Domain: ADC4, COMP1/2, DAC1, I2C3, LPDMA1, LPGPIO, LPTIM1/2/3, LPUART1, OPAMP1/2, SPI3, VREFBUF.

  • According to the LPDMA implementation in the Smart run domain, the LPBAM has access only to SRAM4.

  • The LPBAM mechanism implementation can run autonomously until Stop2 mode. • To reach the lowest power consumption, the system power usage, the system clock and the autonomous peripheral kernel clock can be configured:

An LPBAM project is composed of a main project, and of one or more LPBAM applications.

Figure 698. LPBAM project

image728

The “Main project” contains the “SoC and IPs configuration” at initialization time and a runtime description of the main application. STM32CubeMX allows to describe the “SOC and IPs Configuration” part.

Each LPBAM application contains a “SoC and IPs configuration” and a runtime description. STM32CubeMX allows to describe both.

STM32CubeMX generated code for “SoC and IPs configurations” uses the STM32Cube HAL and/or LL APIs, for both the main project and the LPBAM application. The code generated for the LPBAM application runtime uses the LPBAM firmware API.

Figure 699 is an example of what can be executed at runtime for a simple LPBAM project composed of the main application and of one LPBAM application.

Figure 699. Project timeline

image729

18.2 Creating an LPBAM project

When a project with LPBAM feature capability is opened, a dedicated entry is shown in the user interface (see Figure 700). The feature is optional and when it is not used, it has no impact on the generated project.

image730

Describing an LPBAM project in STM32CubeMX consists in describing the main project using STM32CubeMX main project page, and one or more LPBAM applications using the dedicated LPBAM Scenario & Configuration page.

Starting with STM32CubeMX 6.5:

  • Create a project by selecting an MCU or board part number from the STM32U575/585 product line.

  • Do not activate TrustZone for the project.

  • Click “LPBAM Scenario & Configuration” ribbon to view LPBAM dedicated page.

The LPBAM context is highlighted with a pink border. You can switch back and forth between the main project configuration and the LPBAM Scenario & Configuration by clicking the corresponding ribbon.

image731

When entering the LPBAM Scenario & Configuration view, you must first add an LPBAM application.

Adding, removing, renaming, and switching between LPBAM applications is done from the left panel under the LPBAM manager section.

To add the first LPBAM application, click “Add Application”:

  • If the default name is kept, the application “LpbamApp1” is created.

  • The first Queue “Queue1” of LpbamApp1 is created.

  • The configuration views (LPBAM scenario, pinout & ip, clock) necessary to describe Lpbam App1 are available.

To add more queues, click “Add Queue”

To delete an application (or a queue), right-click the application (or the queue) name and select “Delete”.

To rename an application (or a queue), right-click the application (or the queue) name and select “Rename”. Note that the application name is used in the generated project.

To switch between LPBAM applications, click the application name, this loads the LPBAM panel for the selected application.

To switch between queues in an LPBAM application, click the queue name: the middle and right panels are refreshed to display the selected queue and its configuration.

Figure 702. Adding an application

image732

18.3 Describing an LPBAM application

Describing an LPBAM application consists in configuring the SoC and IPs, as it is done for a standard STM32CubeMX project, as well as describing the runtime part of the application.

To configure IP and SOC in the context of an LPBAM application, use the Pinout & Configuration and Clock configuration provided with the LPBAM application.

Figure 703. SoC and IPs configuration

image733

With standard STM32CubeMX projects, the user must add the code to manage the runtime behavior of the main application based on STM32Cube HAL or LL driver APIs, such as HAL_COMP_Start, HAL_TIM_Start, HAL_TIM_Stop.

For LPBAM applications, STM32CubeMX provides the LPBAM Scenario & Configuration panel to create the runtime description (scenario). As shown in Figure 704, this panel is divided in three parts.

Figure 704. LPBAM scenario: creation and configuration panels

image734

Note: LPBAM applications use the LPBAM firmware APIs and consist of chained DMA transfers.

In the context of an LPBAM application, the first panel is used for:

  • Managing queues for the application.

  • Browsing and adding nodes to the queue currently selected in STM32CubeMX user interface.

  • Application specific settings. These settings cannot be changed nor disabled when using LPBAM on STM32U5 series.

The second panel displays the diagram of the queue currently selected for one selected queue of the LPBAM application.

The third panel lets the user to configure either the queue (if the queue name is clicked), or a node (if the node is selected on the diagram).

The LPBAM subsystem is functional down to STOP2 mode and supports only IPs on the Smart run domain. Consequently, in the LPBAM context, only a subset of the clock tree can be configured. Refer to Section 4.10 for details on how to configure a clock tree in

STM32CubeMX.

image735

Only IPs of the Smart run domain are available in the LPBAM context.

In the LPBAM context, most IPs show the same configuration possibilities as the main project. However, for some IPs, some additional configuration is needed. For example, when an IP internal interrupt can be used in the LPBAM context, a dedicated configuration Tab is shown.

Figure 706. Available IPs

image736

image737

All IPs used at runtime by the LPBAM must be configured in the Pinout & Configuration view. Their configuration must be coherent with the LPBAM scenario.

Clicking “Check LPBAM Design” on the upper right corner of the user interface returns, for each IP used but not configured in an LPBAM application, a warning in the output window.

Warning: “Check LPBAM Design” checks only that the IPs are configured in the “Pinout & Configuration”, it does not check whether the HAL configuration is coherent with the LPBAM APIs used in the scenario.

Starting with STM32CubeMX6.5, users can configure low power settings for their project. These settings (to be found under the PWR IP) are very important to minimize the power consumption of an LPBAM application.

image738

An LPBAM scenario consists of one or more queues, each with one or more nodes. The center panel describes the scenario of the LPBAM application: click the queue name to display its diagram in the center panel and its configuration in the right panel. The name of the selected queue is underlined in blue.

To add more queues, click the “+” button in that panel, or click “Add queues” from the LPBAM management section in the left panel:

  • The maximum number of queues is four on STM32U5 series, limited by the number of LPDMA1 channels.

  • Adding an LPBAM application to the project automatically creates one empty queue for that application.

Warning: For LPBAM applications with multiple queues, STM32CubeMX does not manage the runtime synchronization between queues. It is the user’s responsibility when assembling its final application to “start” the different queues at runtime.

The “LPBAM Management” section allows to remove and rename queues:

  • To delete a queue, right-click the queue name and select “Delete”.

  • To rename a queue, right-click the queue name and select “Rename”.

  • To switch between queues in an LPBAM application, click the queue name: the middle and right panels are refreshed to display the selected queue and its configuration.

A queue description consists of a sequence of functional nodes on a timeline: the sequence is displayed as a diagram in the central panel and the queue configuration in the right panel.

To add nodes to a queue:

  • Click the name of the queue to be updated.

  • Use the “LPBAM function Toolbox”, in the left panel to browse the list of IPs and functions (LPBAM firmware APIs) that can be used to create nodes.

  • Click the IP name to expand and see the list of available functions. • Click the “+” sign next to the function name to add the function as a node in the queue:

the queue diagram in the center panel is updated accordingly.

  • Example: on Queue1 of LpbamAp1, COMP1 is started, then data transfer on COMP1 Output is performed (see Figure 709).

To remove nodes from the diagram, click the cross on the node right-end-upper corner.

Figure 709. Adding nodes to a queue

image739

STM32CubeMX offers the possibility to design circular queues:

  • Select the queue to be configured by clicking the queue name in the center panel: the queue configuration is displayed in the right panel.

  • Click the Circular mode checkbox to configure the queue in circular mode: by default, the queue loops back to the first node (see Figure 710).

  • To loop back to a different node, click the end of the arrow and drag it to the node of choice.

  • To remove the loop, uncheck Circular mode.

image740

Some functions first configure the IP, then manage the data transfer. In case of circular mode, the loop can be plugged on the configuration (“Conf”) or on the data part (“Data”) of the function.

An example is provided in Figure 711: when the queue is executed, the two first nodes and the configuration of the third node are executed once. whereas the data transfer is repeated as part of the loop.

image741

The execution of an LPBAM queue consists of LPDMA chained transfers. The DMA hosting the queue execution must be configured as needed by the application (see Figure 712).

Figure 712. LPBAM queue: DMA configuration

image742

Select the queue to be configured by clicking the queue name on the center panel, the configuration of the DMA channel hosting that queue is shown in the right panel.

Note that some settings usually available for configuring a DMA channel are not provided in the user interface, as they are directly managed either by STM32CubeMX or by the LPBAM driver.

NVIC settings are available only if one DMA channel interrupt is enabled (see right panel in Figure 712). The preemption priority and sub priority ranges in the LPBAM context depend on the NVIC priority group set for the whole project (the main project with the LPBAM applications).

Warning: Always check preemption and sub-priorities in the LPBAM context after changing the NVIC priority group from the main project Pinout & Configuration view.

STM32CubeMX provides contextual help and link to reference documentation on LPBAM functions to guide the user during the function selection process:

  • From the “LPBAM function Toolbox” in the left panel, hover the mouse on an IP name to show the contextual help with links to reference documentation (see Figure 713). • It is recommended to read carefully the LPBAM global documentation and the IP “Description, Usage and Constraint” to learn how to assemble nodes in a queue, several queues, what can be done and what cannot be done. Some restrictions apply and are due to the LPBAM mechanism. They are not coming from the IP itself or from HAL constraints.

    image743

Once a function is chosen from the “LPBAM Function Toolbox” and added to a queue, it can be configured. In the center panel, click on a node to select it: the function is highlighted in pink, and its configuration is shown in the right panel (see Figure 714).

The example shows the “Start” parameters of the LPBAM COMP1_Start function. The HAL driver uses the same parameter names to configure a COMP IP. As mentioned before, the LPBAM firmware is not a HAL driver. However, the IP being unique, the LPBAM driver has been designed so that the IP parameters use, whenever possible, the same naming as found in the HAL driver.

image744

Warning: LPBAM IP functions access IP hardware resources, to be


properly configured in the “Pinout & Configuration” view.

When a parameter is set to a hardware resource such as a GPIO, the resource must be configured in the Pinout & Configuration view.

In the example shown in Figure 714, the COMP “Input Plus” is set to PC5. If PC5 is not configured in the “Pinout & configuration” view, the generated LPBAM application can gets a “null signal” on Input Plus, and will be not functional.

To fix this issue:

  • Go to the Pinout&Configuration view

  • Search PC5 using the search field

  • Right-click the PC5 pin and select COMP_Inp (see Figure 715)

image745

Another example can be made using a timer to generate a PWM signal. The HAL driver requires a timer channel to be configured as output. Same applies when using the LPBAM firmware.

Note: All constraints concerning the initial configuration of the IP are mentioned in the LPBAM firmware documentation. Use STM32CubeMX “LPBAM Design check” mechanism (see dedicated section) to detect missing configurations.

For all IPs and functions, with the LPBAM firmware it is possible to use a hardware signal to trigger a node. STM32CubeMX allows to configure such trigger from the node configuration panel. By default, the node execution is not triggered. When trigger is enabled, all possible trigger signals are listed.

Warning: It is the user responsibility to properly configure the triggers. STM32CubeMX does not check for configuration errors.

Taking the COMP function “Start” as an example (see Figure 716), choose the function execution to be triggered on the rising edge of hardware signal, for the example, then, select the hardware signal among the list of hardware signals proposed.

Figure 716. LPBAM node trigger configuration

image746

If a node is a function managing LPTIM1_CH1, it is possible to select LPTIM1_CH1 as the trigger (see Figure 717).

image747

Nodes set to a function managing data transfers (all functions with associated data transfer and with a name not ending with _Config), come with a specific configuration section: “Reconfigure DMA for Data Transfer” (see Figure 718).

Each DMA data transfer is based on a specific configuration, including, among others, data size, buffer address, address increment. The DMA default settings are functional.

Figure 718. LPBAM node: reconfiguring a DMA

image748

DMA settings can be changed, but they depend upon the IP and the function.

For example, for “COMP Output Level”: - Data transferred are output data and are transferred from the register IP to the memory. The “Source Address” referring to the IP data register is not incremented: STM32CubeMX user interface shows that the “Source address increment after transfer” parameter cannot be enabled. - Data transferred to memory can be saved at the same memory address, or in a Table:

in this case, the “Destination Address increment after transfer” can be disabled or left enabled (see Figure 718).

Figure 719. Reconfiguring DMA for data transfer when destination is memory

image749

18.4 Checking the LPBAM design

STM32CubeMX offers users with the possibility to check their LPBAM design for coherency and completeness, by detecting:

  • Incoherences between the IP LPBAM function selected for a node and the corresponding IP configuration.

  • Wrong queue designs (the sequence of nodes is invalid).

Click CHECK LPBAM DESIGN to check all LPBAM applications currently available in the project. Results appear in the LPBAM output log window (see Figure 720).

Note: Messages raised on the LPBAM design do not prevent users to generate the C code for their project. Supported type of messages are ERROR (in red), Warning (in orange), and Information (in blue).

image750

18.5 Generating a project with LPBAM applications

Click Generate Code from the main project view. As exemplified in Figure 720, the resulting project shows, in addition to the main project files and folders, the stm32_lpbam_conf.h file, a dedicated folder for the configuration code, and the utilities folder with the LPBAM utility firmware.

image751

STM32CubeMX generates:

  • In the Core/Inc folder, the stm32_lpbam_conf.h file that defines all the LPBAM modules enabled for the LPBAM applications, to be used by the LPBAM utility firmware.

  • In the LPBAM folder, the code for the LPBAM applications and their scenarios. The lpbam_<application name>.h file provides the prototypes of the functions to call in the main project to initialize the application, build and initialize the scenario, link it with the DMA, start it, stop it, unlink it, and de-initialize it.

As an example, for the LpbamAp1 application, STM32CubeMX generates the following functions:

/* LpbamAp1 application initialization */ void MX_LpbamAp1_Init(void);

/* LpbamAp1 application - scenario initialization */ void MX_LpbamAp1_Scenario_Init(void);

/* LpbamAp1 application - scenario build */ void MX_LpbamAp1_Scenario_Build(void);

/* LpbamAp1 application - scenario link */ void MX_LpbamAp1_Scenario_Link(DMA_HandleTypeDef *hdma);

/* LpbamAp1 application - scenario start */ void MX_LpbamAp1_Scenario_Start(DMA_HandleTypeDef *hdma); /* LpbamAp1 application - scenario stop */ void MX_LpbamAp1_Scenario_Stop(DMA_HandleTypeDef *hdma);

/* LpbamAp1 application - scenario unlink */ void MX_LpbamAp1_Scenario_UnLink(DMA_HandleTypeDef *hdma);

/* LpbamAp1 application - scenario de-initialization */ void MX_LpbamAp1_Scenario_DeInit(void);

18.6 LPBAM application for TrustZone activated projects

Starting with STM32CubeMX 6.6.0, users can create LPBAM applications for projects with TrustZone activated.

  1. Access to MCU selector and select an STM32U575/585 device

  2. Click Create a new project

  3. Choose the option “with TrustZone activated”

STM32CubeMX standard project view proposes security settings for peripherals ( Figure 722) and the clock tree ( Figure 723).

In STM32CubeMX LPBAM Application configuration context, the peripherals and the clock tree do not come with dedicated security settings (see Figure 724 and Figure 725). The choice of context, secure or nonsecure, is done at LPBAM application level ( Figure 726).

  1. Click image752

  2. Enable Show Attribute Warning Messages to see details about LPBAM security related configuration issues (see Figure 727)

image753

image754

image755

image756

Appendix A STM32CubeMX pin assignment rules

The following pin assignment rules are implemented in STM32CubeMX:

  • Rule 1: Block consistency

  • Rule 2: Block inter-dependency

  • Rule 3: One block = one peripheral mode

  • Rule 4: Block remapping (only for STM32F10x)

  • Rule 5: Function remapping

  • Rule 6: Block shifting (only for STM32F10x)

  • Rule 7: Setting or clearing a peripheral mode

  • Rule 8: Mapping a function individually (if Keep Current Placement is unchecked)

  • Rule 9: GPIO signals mapping

A.1 Block consistency

When setting a pin signal (provided there is no ambiguity about the corresponding peripheral mode), all the pins/signals required for this mode are mapped and pins are shown in green (otherwise the configured pin is shown in orange).

When clearing a pin signal, all the pins/signals required for this mode are unmapped simultaneously and the pins turn back to gray.

If the user assigns I2C1_SMBA function to PB5, then STM32CubeMX configures pins and modes as follows:

  • I2C1_SCL and I2C1_SDA signals are mapped to the PB6 and PB7 pins, respectively (see Figure 728).

  • I2C1 peripheral mode is set to SMBus-Alert mode.

Figure 728. Block mapping

image757

If the user assigns GPIO_Output to PB6, STM32CubeMX automatically disables I2C1 SMBus-Alert peripheral mode from the peripheral tree view and updates the other I2C1 pins (PB5 and PB7) as follows:

  • If they are unpinned, the pin configuration is reset (pin grayed out). • If they are pinned, the peripheral signal assigned to the pins is kept and the pins are highlighted in orange since they no longer match a peripheral mode (see Figure 729).

    Figure 729. Block remapping

image758

For STM32CubeMX to find an alternative solution for the I2C peripheral mode, the user will need to unpin I2C1 pins and select the I2C1 mode from the peripheral tree view (see Figure 730 and Figure 731).

image759

image760

A.2 Block inter-dependency

On the Pinout view, the same signal can appear as an alternate function for multiple pins. However it can be mapped only once.

As a consequence, for STM32F1 MCUs, two blocks of pins cannot be selected simultaneously for the same peripheral mode: when a block/signal from a block is selected, the alternate blocks are cleared.

If SPI1 full-duplex master mode is selected from the tree view, by default the corresponding SPI signals are assigned to PB3, PB4 and PB5 pins (see Figure 732).

If the user assigns to PA6 the SPI1_MISO function currently assigned to PB4,

STM32CubeMX clears the PB4 pin from the SPI1_MISO function, as well as all the other pins configured for this block, and moves the corresponding SPI1 functions to the relevant pins in the same block as the PB4 pin (see Figure 733).

(by pressing CTRL and clicking PB4 to show PA6 alternate function in blue, then drag and drop the signal to pin PA6)

image761

image762

A.3 One block = one peripheral mode

When a block of pins is fully configured in the Pinout view (shown in green), the related peripheral mode is automatically set in the Peripherals tree.

Assigning the I2C1_SMBA function to PB5 automatically configures I2C1 peripheral in SMBus-Alert mode (see Peripheral tree in Figure 734).

Figure 734. One block = one peripheral mode - I2C1_SMBA function assigned to PB5

image763

A.4 Block remapping (STM32F10x only)

To configure a peripheral mode, STM32CubeMX selects a block of pins and assigns each mode signal to a pin in this block. In doing so, it looks for the first free block to which the mode can be mapped.

When setting a peripheral mode, if at least one pin in the default block is already used,

STM32CubeMX tries to find an alternate block. If none can be found, it either selects the

functions in a different sequence, or unchecks image764, and remaps all the blocks to find a solution.

STM32CubeMX remaps USART3 hardware-flow-control mode to the (PD8-PD9-PD11PD12) block, because PB14 of USART3 default block is already allocated to the SPI2_MISO function (see Figure 735).

image765

A.5 Function remapping

To configure a peripheral mode, STM32CubeMX assigns each signal of the mode to a pin. In doing so, it will look for the first free pin the signal can be mapped to.

When configuring USART3 for the Synchronous mode, STM32CubeMX discovered that the default PB10 pin for USART3_TX signal was already used by SPI. It thus remapped it to PD8 (see Figure 736).

image766

A.6 Block shifting (only for STM32F10x and when

“Keep Current Signals placement” is unchecked)

If a block cannot be mapped and there are no free alternate solutions, STM32CubeMX tries to free the pins by remapping all the peripheral modes impacted by the shared pin.

With the Keep current signal placement enabled, if USART3 synchronous mode is set first, the Asynchronous default block (PB10-PB11) is mapped and Ethernet becomes unavailable (shown in red) (see Figure 737).

Unchecking image767 allows STM32CubeMX shifting blocks around and freeing a block for the Ethernet MII mode. (see Figure 738).

Figure 737. Block shifting not applied

image768

Figure 738. Block shifting applied

image769

A.7 Setting and clearing a peripheral mode

The Peripherals panel and the Pinout view are linked: when a peripheral mode is set or cleared, the corresponding pin functions are set or cleared.

A.8 Mapping a function individually

When STM32CubeMX needs a pin that has already been assigned manually to a function (no peripheral mode set), it can move this function to another pin, only if image770 is unchecked and the function is not pinned (no pin icon).