{"id":11194,"date":"2020-06-18T15:23:52","date_gmt":"2020-06-18T15:23:52","guid":{"rendered":"http:\/\/blog.bachi.net\/?p=11194"},"modified":"2021-06-18T08:02:09","modified_gmt":"2021-06-18T08:02:09","slug":"stm32cube-ecosystem","status":"publish","type":"post","link":"https:\/\/blog.bachi.net\/?p=11194","title":{"rendered":"STM32Cube Ecosystem"},"content":{"rendered":"<p><!-- --------------------------------------------------------------------------------------- --><br \/>\n<a href=\"https:\/\/www.st.com\/content\/st_com\/en\/stm32cube-ecosystem.html\">STM32Cube Ecosystem<\/a><br \/>\n<a href=\"https:\/\/my.st.com\/content\/my_st_com\/en\/products\/development-tools\/software-development-tools\/stm32-software-development-tools\/stm32-configurators-and-code-generators\/stm32cubemx.html\">STM32CubeMX<\/a><br \/>\n<a href=\"https:\/\/my.st.com\/content\/my_st_com\/en\/products\/development-tools\/software-development-tools\/stm32-software-development-tools\/stm32-ides\/stm32cubeide.html\">STM32CubeIDE<\/a><\/p>\n<p><a href=\"https:\/\/www.st.com\/en\/embedded-software\/stm32cubef3.html\">STM32CubeF3<\/a><\/p>\n<table>\n<tr>\n<td>STM32Cube<\/td>\n<td>STM32Cube is a combination of software tools and embedded software libraries<\/td>\n<\/tr>\n<tr>\n<td>STM32CubeMX<\/td>\n<td>A configuration tool for any STM32 device. This easy-to-use graphical user interface generates initialization C code for Cortex-M cores and generates the Linux device tree source for Cortex-A cores<\/td>\n<\/tr>\n<tr>\n<td>STM32CubeIDE<\/td>\n<td>An Integrated Development Environment. Based on open-source solutions like Eclipse or the GNU C\/C++ toolchain, this IDE includes compilation reporting features and advanced debug features. It also integrate additional features present in other tools from the ecosystem, such as the HW and SW initilialization and code generation from STM32CubeMX.<\/td>\n<\/tr>\n<tr>\n<td>STM32CubeProgrammer<\/td>\n<td>A programming tool. It provides an easy-to-use and efficient environment for reading, writing and verifying devices and external memories via a wide variety of available communication media (JTAG, SWD, UART, USB DFU, I2C, SPI, CAN, etc.).<\/td>\n<\/tr>\n<tr>\n<td>STM32CubeMonitor<\/td>\n<td>Family of tools. Powerful monitoring tools that help developers fine-tune the behavior and performance of their applications in real time.<\/td>\n<\/tr>\n<tr>\n<td>STM32Cube MCU and MPU packages<\/td>\n<td>Dedicated to each STM32 series. Packages offer all the required embedded software bricks to operate the available set of STM32 peripherals. They include drivers (HAL, low-layer, etc.), middleware, and lots of example code used in a wide variety of real-world use cases.<\/td>\n<\/tr>\n<tr>\n<td>STM32Cube expansion packages<\/td>\n<td>For application-oriented solutions. Complementing and expanding the STM32Cube MCU Package offer with additional embedded software bricks, STM32 expansion packages come either from ST or approved partners to create an extensive and scalable embedded software offer around the STM32.<\/td>\n<\/tr>\n<\/table>\n<p><!-- --------------------------------------------------------------------------------------- --><\/p>\n<h3>Pros &#038; Cons<\/h3>\n<p><a href=\"https:\/\/www.st.com\/resource\/en\/user_manual\/dm00104712-stm32cubemx-for-stm32-configuration-and-initialization-c-code-generation-stmicroelectronics.pdf\">UM1718 &#8211; User manual &#8211; STM32CubeMX for STM32 configuration<br \/>\nand initialization C code generation<\/a> (PDF)<\/p>\n<p><a href=\"https:\/\/datarespons.com\/pros-cons-using-stm32cubemx-code-generation-tool-insead-manually-writing-drivers-arm-cortex-m-microcontroller\/\">Pros &#038; cons of using STM32CubeMX code generation tool insead of manually writing drivers for an ARM Cortex-M microcontroller<\/a><\/p>\n<p><!-- --------------------------------------------------------------------------------------- --><\/p>\n<h3>Migration<\/h3>\n<table>\n<tr>\n<td>From SW4STM32 to STM32CubeIDE<\/td>\n<td>Previously, developers could use SW4STM32 a free version of System Workbench that supports our entire lineup of microcontrollers. STM32CubeIDE already supports almost all our microcontrollers, except the STM32MP1, which is the first STM32 MPU.<\/td>\n<\/tr>\n<tr>\n<td>From TrueSTUDIO to STM32CubeIDE<\/td>\n<td>Developers also had an alternative to SW4STM32 in the form of TrueSTUDIO, which ST bought along with its acquisition of Atollic in 2017. STM32CubeIDE gets all these features and more, ensuring that people will not miss TrueSTUDIO.<\/td>\n<\/tr>\n<\/table>\n<p><!-- --------------------------------------------------------------------------------------- --><\/p>\n<h3>STLinkUpgrade<\/h3>\n<table>\n<tr>\n<td><a href=\"http:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/STLinkUpgrade_2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/STLinkUpgrade_2-300x129.png\" alt=\"\" width=\"300\" height=\"129\" class=\"alignleft size-medium wp-image-11334\" srcset=\"https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/STLinkUpgrade_2-300x129.png 300w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/STLinkUpgrade_2-624x268.png 624w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/STLinkUpgrade_2.png 718w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td><a href=\"http:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/STLinkUpgrade_3.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/STLinkUpgrade_3-300x129.png\" alt=\"\" width=\"300\" height=\"129\" class=\"alignleft size-medium wp-image-11335\" srcset=\"https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/STLinkUpgrade_3-300x129.png 300w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/STLinkUpgrade_3-624x268.png 624w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/STLinkUpgrade_3.png 718w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/td>\n<\/tr>\n<\/table>\n<p><!-- --------------------------------------------------------------------------------------- --><\/p>\n<h3>Command Line Tools<\/h3>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&gt; set PATH=%PATh%;c:\\ST\\STM32CubeIDE_1.6.0\\STM32CubeIDE\\plugins\\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924\\tools\\bin\r\n&gt; path\r\nPATh=&#x5B;...]\r\n&gt; arm-none-eabi-gcc\r\narm-none-eabi-gcc: fatal error: no input files\r\n<\/pre>\n<p><!-- --------------------------------------------------------------------------------------- --><\/p>\n<h3>STM32CubeMX C Code generation<\/h3>\n<p>STM32CubeMX: STM32Cube initialization code generator<\/p>\n<p>STM32CubeMX is a graphical tool that allows a very easy configuration of STM32 microcontrollers and microprocessors, as well as the generation of the corresponding initialization C code for the Arm Cortex-M core, through a step-by-step process.<\/p>\n<h4>6.1 STM32Cube code generation using only HAL drivers<\/h4>\n<p>During the C code generation process, STM32CubeMX performs the following actions:downloads the relevant STM32Cube MCU package<\/p>\n<ol>\n<li>Downloads the relevant STM32Cube MCU package<\/li>\n<li>It copies from the firmware package, the relevant files<\/li>\n<li>It generates the initialization C code (<code>.c\/.h<\/code> files) corresponding to the user MCU configuration and stores it in the <code>Inc<\/code> and <code>Src<\/code> folders.<\/li>\n<\/ol>\n<ul>\n<li>stm32f4xx_hal_conf.h<\/li>\n<li>stm32f4xx_hal_msp.c (MSP = MCU Support package):main.c<\/li>\n<li>main.c<\/li>\n<li>main.h<\/li>\n<\/ul>\n<p>See also:<\/p>\n<ul>\n<li><code>stm32f4xx_hal_conf.h<\/code><\/li>\n<li><code>stm32f4xx_hal_msp.c<\/code> (MSP = MCU Support package)<\/li>\n<li><code>main.c<\/code><\/li>\n<li><code>main.h<\/code><\/li>\n<\/ul>\n<table>\n<tr>\n<td><a href=\"http:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/DM00105879_figure_7.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/DM00105879_figure_7-1024x886.png\" alt=\"\" width=\"625\" height=\"541\" class=\"alignleft size-large wp-image-11919\" srcset=\"https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/DM00105879_figure_7-1024x886.png 1024w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/DM00105879_figure_7-300x260.png 300w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/DM00105879_figure_7-768x665.png 768w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/DM00105879_figure_7-1536x1329.png 1536w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/DM00105879_figure_7-624x540.png 624w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/DM00105879_figure_7.png 1621w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td><a href=\"http:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/HAL_MSPInit.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/HAL_MSPInit-300x123.png\" alt=\"\" width=\"300\" height=\"123\" class=\"alignleft size-medium wp-image-11336\" srcset=\"https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/HAL_MSPInit-300x123.png 300w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/HAL_MSPInit.png 404w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td><a href=\"http:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/mspinit.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/mspinit-1024x725.png\" alt=\"\" width=\"625\" height=\"443\" class=\"alignleft size-large wp-image-11920\" srcset=\"https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/mspinit-1024x725.png 1024w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/mspinit-300x213.png 300w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/mspinit-768x544.png 768w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/mspinit-624x442.png 624w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/mspinit.png 1344w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a><\/td>\n<\/tr>\n<\/table>\n<h4>MSP<\/h4>\n<p><a href=\"https:\/\/www.openstm32.org\/forumthread2231\">What means the Msp in HAL_MspInit ? <\/a><br \/>\n<a href=\"https:\/\/stackoverflow.com\/questions\/37514022\/what-does-the-msp-in-stm32cubemx-hal-xxx-mspinit-functions-stand-for\">What does the MSP in STM32CubeMX HAL_xxx_MspInit() functions stand for?<\/a><\/p>\n<p>The ST HAL is designed so that the SPI module of the HAL is generic and abstracts from the specific I\/O settings, which may differ due to the MCU package and the user-defined hardware configuration. So, ST developers have leaved to the user the responsibility to &#8220;fill&#8221; this piece of the HAL with the code necessary to configure the peripheral, using a sort of callback routines. Source<\/p>\n<p><!-- --------------------------------------------------------------------------------------- --><\/p>\n<h3>HAL vs. LL<\/h3>\n<p>The HAL and LL are complementary and cover a wide range of application requirements:<\/p>\n<ul>\n<li>The HAL offers high-level and feature-oriented APIs with a high-portability level. These hide the MCU and peripheral complexity from the end-user.<\/li>\n<li>The LL offers low-level APIs at register level, with better optimization but less portability. These require deep knowledge of the MCU and peripheral specifications<\/li>\n<\/ul>\n<p><a href=\"https:\/\/community.st.com\/s\/question\/0D50X00009XkhQSSAZ\/hal-vs-ll\">HAL vs LL<\/a><br \/>\n<a href=\"https:\/\/electronics.stackexchange.com\/questions\/456015\/stm32-hal-vs-ll\">STM32 HAL vs LL<\/a><br \/>\n<a href=\"https:\/\/stackoverflow.com\/questions\/47972831\/how-to-use-ll-low-level-drivers-in-cubemx-stm32\">How to use LL (low level) drivers in CubeMX STM32?<\/a><\/p>\n<h4>YouTube<\/h4>\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=an29DWiPh8A\">STM32G0 Workshop &#8211; Pt. 8, Low Layer Drivers<\/a><\/p>\n<p><!-- --------------------------------------------------------------------------------------- --><\/p>\n<h3>Interrupts<\/h3>\n<div><a href=\"http:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/nvic_usart3_enable2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/nvic_usart3_enable2-300x152.png\" alt=\"\" width=\"300\" height=\"152\" class=\"alignleft size-medium wp-image-12022\" srcset=\"https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/nvic_usart3_enable2-300x152.png 300w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/nvic_usart3_enable2-1024x519.png 1024w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/nvic_usart3_enable2-768x389.png 768w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/nvic_usart3_enable2-624x316.png 624w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/nvic_usart3_enable2.png 1418w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/div>\n<pre class=\"brush: cpp; title: Core\/Src\/stm32g4xx_it.c; notranslate\" title=\"Core\/Src\/stm32g4xx_it.c\">\r\n\r\ng_pfnVectors:\r\n\t.word\t_estack\r\n\t.word\tReset_Handler\r\n\t.word\tNMI_Handler\r\n\t.word\tHardFault_Handler\r\n\t.word\tMemManage_Handler\r\n\t.word\tBusFault_Handler\r\n\t.word\tUsageFault_Handler\r\n        &#x5B;...]\r\n\t.word\tUSART3_IRQHandler\r\n        &#x5B;...]\r\n<\/pre>\n<pre class=\"brush: cpp; title: Core\/Src\/stm32g4xx_it.c; notranslate\" title=\"Core\/Src\/stm32g4xx_it.c\">\r\nvoid USART3_IRQHandler(void)\r\n{\r\n  HAL_UART_IRQHandler(&amp;huart3);\r\n}\r\n<\/pre>\n<pre class=\"brush: cpp; title: Drivers\/STM32G4xx_HAL_Driver\/Src\/stm32g4xx_hal_uart.c; notranslate\" title=\"Drivers\/STM32G4xx_HAL_Driver\/Src\/stm32g4xx_hal_uart.c\">\r\nvoid HAL_UART_IRQHandler(UART_HandleTypeDef *huart)\r\n{\r\n  &#x5B;...]\r\n  \/* UART in mode Transmitter (transmission end) -----------------------------*\/\r\n  if (((isrflags &amp; USART_ISR_TC) != 0U) &amp;&amp; ((cr1its &amp; USART_CR1_TCIE) != 0U))\r\n  {\r\n    UART_EndTransmit_IT(huart);\r\n    return;\r\n  }\r\n  &#x5B;...]\r\n}\r\n\r\nstatic void UART_EndTransmit_IT(UART_HandleTypeDef *huart)\r\n{\r\n  &#x5B;...]\r\n#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)\r\n    \/*Call registered Tx complete callback*\/\r\n    huart-&gt;TxCpltCallback(huart);\r\n#else\r\n    \/*Call legacy weak Tx complete callback*\/\r\n    HAL_UART_TxCpltCallback(huart);\r\n#endif \/* USE_HAL_UART_REGISTER_CALLBACKS *\/\r\n  &#x5B;...]\r\n}\r\n\r\n__weak void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)\r\n{\r\n\r\n}\r\n<\/pre>\n<pre class=\"brush: cpp; title: Drivers\/STM32G4xx_HAL_Driver\/Inc\/stm32g4xx_hal_uart.h; notranslate\" title=\"Drivers\/STM32G4xx_HAL_Driver\/Inc\/stm32g4xx_hal_uart.h\">\r\n\/* Callbacks Register\/UnRegister functions  ***********************************\/\r\n#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)\r\nHAL_StatusTypeDef HAL_UART_RegisterCallback(UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID,\r\n                                            pUART_CallbackTypeDef pCallback);\r\nHAL_StatusTypeDef HAL_UART_UnRegisterCallback(UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID);\r\n\r\nHAL_StatusTypeDef HAL_UART_RegisterRxEventCallback(UART_HandleTypeDef *huart, pUART_RxEventCallbackTypeDef pCallback);\r\nHAL_StatusTypeDef HAL_UART_UnRegisterRxEventCallback(UART_HandleTypeDef *huart);\r\n#endif \/* USE_HAL_UART_REGISTER_CALLBACKS *\/\r\n<\/pre>\n<p><!-- --------------------------------------------------------------------------------------- --><\/p>\n<h3>Critical Section \/ Mutex<\/h3>\n<p>Backlink: <a href=\"http:\/\/blog.bachi.net\/?p=11905\">ARM Cortex-M4 Atomic \/ Mutex \/ Read-Modify-Write<\/a><br \/>\nBacklink: <a href=\"http:\/\/blog.bachi.net\/?p=11934\">STM32 Spinlock vs. Interruptlock<\/a><\/p>\n<p><a href=\"https:\/\/stm32f4-discovery.net\/2015\/06\/how-to-properly-enabledisable-interrupts-in-arm-cortex-m\/\">How to properly enable\/disable interrupts in ARM Cortex-M?<\/a><\/p>\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/51795537\/critical-sections-in-arm\">Critical sections in ARM<\/a><\/p>\n<p><a href=\"https:\/\/community.st.com\/s\/question\/0D50X0000BVmd12SQB\/stm32l4-critical-section\">STM32L4 CRITICAL SECTION<\/a><br \/>\n<a href=\"https:\/\/community.st.com\/s\/question\/0D50X0000C5Tns8SQC\/bug-stm32-hal-driver-lock-mechanism-is-not-interrupt-safe\">STM32 HAL driver lock mechanism is not interrupt safe<\/a><\/p>\n<p><a href=\"https:\/\/www.freertos.org\/taskENTER_CRITICAL_taskEXIT_CRITICAL.html\">FreeRTOS taskENTER_CRITICAL()<\/a><br \/>\n<a href=\"https:\/\/www.freertos.org\/taskENTER_CRITICAL_FROM_ISR_taskEXIT_CRITICAL_FROM_ISR.html\">FreeRTOS taskENTER_CRITICAL_FROM_ISR()<\/a><\/p>\n<ul>\n<li>Global: <code>__get_PRIMASK()<\/code>, <code>__disable_irq()<\/code>, <code>__enable_irq()<\/code><\/li>\n<li>Peripheral: <code>HAL_NVIC_DisableIRQ(EXTI4_15_IRQn) <\/code><\/li>\n<li>Macro: <code>__HAL_TIM_ENABLE_IT(__HANDLE__, __INTERRUPT__)<\/code>, <code>__HAL_TIM_DISABLE_IT(__HANDLE__, __INTERRUPT__)<\/code><\/li>\n<li>Macro: <code>__HAL_ENTER_CRITICAL_SECTION()<\/code>, <code>__HAL_EXIT_CRITICAL_SECTION()<\/code><\/li>\n<li>HAL-only? (no interrupt?): <code>HAL_Lock(lock)<\/code>, <code>HAL_UnLock(lock)<\/code><\/li>\n<\/ul>\n<pre class=\"brush: cpp; title: Drivers\/STM32G4xx_HAL_Driver\/Inc\/stm32g4xx_hal_cortex.h; notranslate\" title=\"Drivers\/STM32G4xx_HAL_Driver\/Inc\/stm32g4xx_hal_cortex.h\">\r\nvoid HAL_NVIC_EnableIRQ(IRQn_Type IRQn);\r\nvoid HAL_NVIC_DisableIRQ(IRQn_Type IRQn);\r\n<\/pre>\n<pre class=\"brush: cpp; title: Drivers\/STM32G4xx_HAL_Driver\/Src\/stm32g4xx_hal_cortex.c; notranslate\" title=\"Drivers\/STM32G4xx_HAL_Driver\/Src\/stm32g4xx_hal_cortex.c\">\r\nvoid HAL_NVIC_EnableIRQ(IRQn_Type IRQn);\r\nvoid HAL_NVIC_DisableIRQ(IRQn_Type IRQn);\r\n<\/pre>\n<pre class=\"brush: cpp; title: Drivers\/STM32G4xx_HAL_Driver\/Inc\/stm32g4xx_hal_def.h; notranslate\" title=\"Drivers\/STM32G4xx_HAL_Driver\/Inc\/stm32g4xx_hal_def.h\">\r\n\/* @brief  HAL Lock structures definition *\/\r\ntypedef enum\r\n{\r\n  HAL_UNLOCKED = 0x00U,\r\n  HAL_LOCKED   = 0x01U\r\n} HAL_LockTypeDef;\r\n\r\n#if (USE_RTOS == 1U)\r\n\/* Reserved for future use *\/\r\n#error &quot; USE_RTOS should be 0 in the current HAL release &quot;\r\n#else\r\n#define __HAL_LOCK(__HANDLE__)             \\\r\n  do{                                      \\\r\n    if((__HANDLE__)-&gt;Lock == HAL_LOCKED)   \\\r\n    {                                      \\\r\n      return HAL_BUSY;                     \\\r\n    }                                      \\\r\n    else                                   \\\r\n    {                                      \\\r\n      (__HANDLE__)-&gt;Lock = HAL_LOCKED;     \\\r\n    }                                      \\\r\n  }while (0U)\r\n\r\n#define __HAL_UNLOCK(__HANDLE__)           \\\r\n  do{                                      \\\r\n    (__HANDLE__)-&gt;Lock = HAL_UNLOCKED;     \\\r\n  }while (0U)\r\n#endif \/* USE_RTOS *\/\r\n<\/pre>\n<hr\/>\n<p><!-- --------------------------------------------------------------------------------------- --><\/p>\n<h3>SysTick<\/h3>\n<div>\n<a href=\"http:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/stm32_systick_init.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/stm32_systick_init.png\" alt=\"\" width=\"634\" height=\"195\" class=\"alignleft size-full wp-image-12108\" srcset=\"https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/stm32_systick_init.png 634w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/stm32_systick_init-300x92.png 300w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/stm32_systick_init-624x192.png 624w\" sizes=\"auto, (max-width: 634px) 100vw, 634px\" \/><\/a>\n<\/div>\n<pre class=\"brush: cpp; title: Drivers\/STM32G4xx_HAL_Driver\/Src\/stm32g4xx_hal.c; notranslate\" title=\"Drivers\/STM32G4xx_HAL_Driver\/Src\/stm32g4xx_hal.c\">\r\n__weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)\r\n{\r\n  HAL_StatusTypeDef  status = HAL_OK;\r\n\r\n  if (uwTickFreq != 0U) {\r\n    \/* Configure the SysTick to have interrupt in 1ms time basis*\/\r\n    if (HAL_SYSTICK_Config(SystemCoreClock \/ (1000U \/ uwTickFreq)) == 0U) {\r\n      \/* Configure the SysTick IRQ priority *\/\r\n      if (TickPriority &lt; (1UL &lt;&lt; __NVIC_PRIO_BITS)) {\r\n        HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U);\r\n        uwTickPrio = TickPriority;\r\n      }\r\n  &#x5B;...]\r\n\r\n  \/* Return function status *\/\r\n  return status;\r\n}\r\n<\/pre>\n<hr\/>\n<p><!-- --------------------------------------------------------------------------------------- --><\/p>\n<h3>Configuration<\/h3>\n<pre class=\"brush: cpp; title: Core\/Inc\/stm32g4xx_hal_conf.h (auto-generated); notranslate\" title=\"Core\/Inc\/stm32g4xx_hal_conf.h (auto-generated)\">\r\n\r\n\/* ########################## Module Selection ############################## *\/\r\n\/* @brief This is the list of modules to be used in the HAL driver *\/\r\n\r\n#define HAL_I2S_MODULE_ENABLED\r\n#define HAL_SPI_MODULE_ENABLED\r\n#define HAL_TIM_MODULE_ENABLED\r\n#define HAL_UART_MODULE_ENABLED\r\n\r\n\/* ########################## Register Callbacks selection ############################## *\/\r\n\/* @brief This is the list of modules where register callback can be used\r\n          instead of the weak predefined callback *\/\r\n\r\n#define USE_HAL_I2S_REGISTER_CALLBACKS        0U\r\n#define USE_HAL_SPI_REGISTER_CALLBACKS        0U\r\n#define USE_HAL_TIM_REGISTER_CALLBACKS        0U\r\n#define USE_HAL_UART_REGISTER_CALLBACKS       0U\r\n\r\n\/* ########################## Oscillator Values adaptation ####################*\/\r\n\r\n#define HSE_VALUE    (24000000UL) \/*!&lt; Value of the External oscillator in Hz *\/\r\n#define HSE_STARTUP_TIMEOUT    (100UL)   \/*!&lt; Time out for HSE start up, in ms *\/\r\n\r\n\/* ########################### System Configuration ######################### *\/\r\n\/* @brief This is the HAL system configuration section *\/\r\n\r\n#define  VDD_VALUE                   (3300UL) \/*!&lt; Value of VDD in mv *\/\r\n#define  TICK_INT_PRIORITY           (0UL)    \/*!&lt; tick interrupt priority (lowest by default)  *\/\r\n#define  USE_RTOS                     0U\r\n#define  PREFETCH_ENABLE              0U\r\n#define  INSTRUCTION_CACHE_ENABLE     1U\r\n#define  DATA_CACHE_ENABLE            1U\r\n\r\n<\/pre>\n<hr\/>\n<p><!-- --------------------------------------------------------------------------------------- --><\/p>\n<h3>Register Callback<\/h3>\n<div>\n<a href=\"http:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/register_callback.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/register_callback-1024x937.png\" alt=\"\" width=\"625\" height=\"572\" class=\"alignleft size-large wp-image-12103\" srcset=\"https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/register_callback-1024x937.png 1024w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/register_callback-300x275.png 300w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/register_callback-768x703.png 768w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/register_callback-624x571.png 624w, https:\/\/blog.bachi.net\/wp-content\/uploads\/2020\/06\/register_callback.png 1330w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a>\n<\/div>\n<p><!-- --------------------------------------------------------------------------------------- --><\/p>\n<h3>Blog<\/h3>\n<p><a href=\"https:\/\/blog.st.com\/stm32cubeide-free-ide\/\">STM32CubeIDE: The First Free ST IDE with STM32CubeMX Built-in<\/a><\/p>\n<p><!-- --------------------------------------------------------------------------------------- --><\/p>\n<h3>Books \/ eBooks<\/h3>\n<p><a href=\"https:\/\/github.com\/cnoviello\/mastering-stm32\/\">github.com\/cnoviello\/mastering-stm32\/<\/a>, Repository of all examples presented in the &#8220;Mastering STM32&#8221; book<\/p>\n<p><!-- --------------------------------------------------------------------------------------- --><\/p>\n<h3>YouTube<\/h3>\n<p><a href=\"https:\/\/www.youtube.com\/playlist?list=PLnMKNibPkDnGtuIl5v0CvC81Am7SKpj02\">MOOC &#8211; STM32CubeMX and STM32Cube HAL basics<\/a> (Playlist)<br \/>\n<a href=\"https:\/\/www.youtube.com\/playlist?list=PLnMKNibPkDnFCosVVv98U5dCulE6T3Iy8\">MOOC &#8211; STM32CubeIDE basics<\/a><br \/>\n<a href=\"https:\/\/www.youtube.com\/playlist?list=PLnMKNibPkDnG1xN9JSrrwMWt5ngQQchAa\">MOOC &#8211; STM32G0 Workshop<\/a><br \/>\n<a href=\"https:\/\/www.youtube.com\/watch?v=6RqUkFIeN6w\">How to build a \u201cBlink LED\u201d project from STM32CubeMX for ST\/Atollic TrueSTUDIO for STM32<\/a><br \/>\n<a href=\"https:\/\/www.youtube.com\/playlist?list=PLfIJKC1ud8gga7xeUUJ-bRUbeChfTOOBd\">STM32 Tutorials<\/a> by Controllers Tech (Playlist)<br \/>\n<a href=\"https:\/\/www.youtube.com\/watch?v=6Z1L6ox63j0\">DAC in STM32 || Sine wave || HAL || CubeIDE<\/a><br \/>\n<a href=\"https:\/\/www.youtube.com\/watch?v=gGPf8Hhx0VM\">STM32 4 SWO Output<\/a><br \/>\n<a href=\"https:\/\/www.youtube.com\/watch?v=ZA7SUlTO35k\">Tutorial CubeMX 4 External Interrupts EXTI<\/a><\/p>\n<h4>STM32 by Web learning<\/h4>\n<p><a href=\"https:\/\/www.youtube.com\/playlist?list=PLaSBRRMONZaaTOlA4T7OZw6fIEsmMM9fa\">STM32<\/a>, by Web learning (Playlist)<br \/>\n<a href=\"https:\/\/www.youtube.com\/watch?v=jZ6J8oITgK8\">HAL: #1 How to &#8211; GPIO<\/a><br \/>\n<a href=\"https:\/\/www.youtube.com\/watch?v=UtkszckecV8\">HAL: #2 How to &#8211; GPIO Interrupt<\/a><br \/>\n<a href=\"https:\/\/www.youtube.com\/watch?v=YPJlhYm5T8Y\">HAL #10: HowTo Timer with Interrupt<\/a><br \/>\n<a href=\"https:\/\/www.youtube.com\/watch?v=xe7KIdRFRoI\">HAL #11: HowTo use the DAC<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>STM32Cube Ecosystem STM32CubeMX STM32CubeIDE STM32CubeF3 STM32Cube STM32Cube is a combination of software tools and embedded software libraries STM32CubeMX A configuration tool for any STM32 device. This easy-to-use graphical user interface generates initialization C code for Cortex-M cores and generates the Linux device tree source for Cortex-A cores STM32CubeIDE An Integrated Development Environment. Based on open-source [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11194","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/11194","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11194"}],"version-history":[{"count":35,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/11194\/revisions"}],"predecessor-version":[{"id":12334,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/11194\/revisions\/12334"}],"wp:attachment":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11194"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}