SWEN 563 STM32 CubeMX Aux Development Tools Parametric searching - - PowerPoint PPT Presentation

swen 563
SMART_READER_LITE
LIVE PREVIEW

SWEN 563 STM32 CubeMX Aux Development Tools Parametric searching - - PowerPoint PPT Presentation

SWEN 563 STM32 CubeMX Aux Development Tools Parametric searching vendor lists for peripherals/ footprints / memory / cpu types / etc gives only half the story of what resources are available It pays to check out the whole ecosystem


slide-1
SLIDE 1

SWEN 563

STM32 CubeMX

slide-2
SLIDE 2

Aux Development Tools

  • Parametric searching vendor lists for peripherals/ footprints / memory / cpu types / etc…

gives only half the story of what resources are available

  • It pays to check out the whole ecosystem already in place when starting a new project

with an architecture / platform / vendor choice. Not just the data sheets.

  • Which various development stacks (IAR/KEIL/GCC/Arduino?) are available
  • Look for specific forums / Active open source development projects! Bootstrap...
  • Hunt around for additional software and packages the vendor may have

(web based IDE:energia, Low power simulation, capacitive sensing setup software etc..)

Most vendors supply a “Pin configuration Tool” or similar.

slide-3
SLIDE 3

Pin Configuration Tool

Corollary to development:

  • If bare metal programming (Project 1) is like writing in assembly language, then the PIN

configuration tool is like C - a higher level language that abstracts away the details of what’s going on under the hood, freeing the programmer to think at a more conceptual level.

  • Tool typically works across a large selection of the vendors catalog. Including

development or sample boards. TI: PinMUX tool; Microchip: Harmony, Freescale: MCUXpresso; Renesas: Smart Configurator;

And…. ST: CubeMX

slide-4
SLIDE 4

CubeMX

STM32CubeMX is a graphical tool that allows a very easy configuration of STM32 microcontrollers and the generation of the corresponding initialization C code through a step-by-step process.

  • Exposes the entire corpus of the microcontroller (peripherals, clocks, IRQ,DMA etc).
  • Pinout with automatic conflict resolution
  • Peripherals and middleware functional modes with dynamic validation of parameter

constraints

  • Clock tree with dynamic validation of the configuration
  • Power sequence with estimated consumption results
slide-5
SLIDE 5

Tools Function: Generation of templates

  • Generates a Skeleton including:

○ A project tree template for you to use with your tool chain ○ C code (.c and .h) files generated that contain the code needed to configure and initialize the controller the way you set it up in the tool. Including main.c

  • Documentation on pins used and their functions - this can be shared with the electrical

group for verification of the layout or board design. Common for errors between electrical and firmware to crop up, unless documentation goes back and forth well.

  • Tool creates, includes, and uses Hardware Abstraction Layer API

STM HAL / Low Level Driver User Manual: UM1884

slide-6
SLIDE 6

Principle workflow to use of CubeMX Tool

1

Select a Part or board

Determine where you want to start? Don’t forget to consider the chips physical footprint. If the design is already setup and a board profile exists - it may be easier to start with a fully defined board and delete the sections that do not apply to your design or implementation

Setup Clocks

Setup the clocking system for the device. Most peripherals will require configuration here - NOTE the clock prescale dividers for the peripherals (timers)? Look familiar? Some devices (USB for example) require specific clocking configurations or they won’t function 2

Setup Pins

Clicking on individual Pins Allows you to select their primary function from all available functions. This shows you in a much better way what pin can do what function. Also give your pins MEANINGFUL names for their function 3

Setup Peripherals

Starting with SystemCore GPIO section. You can setup PIN physical details. Select and enable the additional peripheral devices you wish to use. And configure the parameters for each peripheral of interest. 4

Generate Code

First: In project Manager make sure that the Project type is set for Keil and the names and directories make sense. Next: Generate Code will produce a complete project that configures and initializes your defined peripherals, and can launch the IDE. 5

slide-7
SLIDE 7

Demo CubeMX Project creation

slide-8
SLIDE 8
  • Change or add code only in

designated areas (between matching BEGIN / END comment lines)

  • In the example, red code was

generated by the tool, and green code by the programmer. Both sections get compiled into the app.

  • Similar to the way PHP or ASP

interact with HTML.

By keeping to your code to designated sections only

  • you can RE-USE the tool later to regenerate the

skeleton without losing any work you may have

  • added. But caution is advised (backup, source

control etc...) /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_DMA_Init(); MX_USART2_UART_Init(); MX_TIM2_Init(); /* USER CODE BEGIN 2 */ sprintf((char *)transmitBuffer,"Hello World!\r\n"); HAL_UART_Transmit_IT(&huart2, transmitBuffer, 32); HAL_GPIO_WritePin(LD_G_GPIO_Port, LD_G_Pin, GPIO_PIN_SET); HAL_TIM_IC_Start_DMA(&htim2, TIM_CHANNEL_1, (uint32_t*) captures, 2); /* USER CODE END 2 */

Using Code generated by CubeMX Tool

slide-9
SLIDE 9

Demo Code Skeleton