{"id":14428,"date":"2023-04-19T10:33:42","date_gmt":"2023-04-19T05:03:42","guid":{"rendered":"https:\/\/fastbitlab.com\/?p=14428"},"modified":"2023-09-07T12:42:53","modified_gmt":"2023-09-07T07:12:53","slug":"stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\/","title":{"rendered":"STM32-LTDC, LCD-TFT, LVGL (MCU3) Lecture 17| Setting up main system clock code implementation part-1"},"content":{"rendered":"<div class=\"boldgrid-section color4-background-color color-4-text-contrast bg-background-color\">\n<div class=\"container\">\n<div class=\"row\">\n<div class=\"col-lg-1 col-md-12 col-sm-12 col-xs-12\"><\/div>\n<div class=\"col-lg-10 col-md-12 col-xs-12 col-sm-12\">\n<p class=\"\">&nbsp;<\/p>\n<h1 class=\"\" style=\"text-align: center; font-size: 40px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000080;\"><strong>Setting up main system clock code implementation part-1<\/strong><\/span><\/h1>\n<div class=\"row bg-editor-hr-wrap\">\n<div class=\"col-lg-12 col-md-12 col-xs-12 col-sm-12\">\n<div>\n<div class=\"bg-hr bg-hr-16 color2-color\" style=\"border-style: solid; border-width: 0px 0px 2px;\"><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p class=\"\" style=\"font-size: 17px; font-family: 'Roboto Slab'; font-weight: 400; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">In this article, we will begin creating the main clock code for our application. Having an accurate clock is essential for many applications and devices, and it&#8217;s no different in our case. The timekeeping module of our application is the backbone of the system, and we need to make sure that it is reliable and accurate.<\/span><\/p>\n<p class=\"\" style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">The project has two header files: <\/span><b>reg_util.h<\/b><span style=\"font-weight: 400;\"> and <\/span><b>stm32f429xx.h<\/b><span style=\"font-weight: 400;\">. These files contain essential information that we need to access the microcontroller&#8217;s registers and set up the clock.<\/span><\/span><\/p>\n<p class=\"\" style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 29px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">The <\/span><b>reg_util.h<\/b><span style=\"font-weight: 400;\"> file contains some macros that we can use to configure the microcontroller&#8217;s registers. These macros are displayed in below. They make our code more readable and understandable by providing us with a shorthand notation for accessing the registers.<\/span><\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"box-shadow: #cecece 0px 0px 0px 0px inset;\"><span style=\"color: #ff0000;\">#ifndef<\/span> <span style=\"color: #99ccff;\">REG_UTIL_H_<\/span>\r\n<span style=\"color: #ff0000;\">#define<\/span> <span style=\"color: #99ccff;\">REG_UTIL_H_<\/span>\r\n\r\n<span style=\"color: #008000;\">\/* Register bit manipulation macros *\/<\/span>\r\n\r\n<span style=\"color: #ff0000;\">#define<\/span> <span style=\"color: #99ccff;\">REG_WRITE<\/span>(reg, val) ((reg) = (val))\r\n<span style=\"color: #ff0000;\">#define<\/span> <span style=\"color: #99ccff;\">REG_READ<\/span>(reg) ((reg))\r\n<span style=\"color: #ff0000;\">#define<\/span> <span style=\"color: #99ccff;\">REG_SET_BIT<\/span>(reg,pos) ((reg) |= (1U &lt;&lt; (pos)))\r\n<span style=\"color: #ff0000;\">#define<\/span> <span style=\"color: #99ccff;\">REG_CLR_BIT<\/span>(reg,pos) ((reg) &amp;= ~(1U &lt;&lt; (pos)))\r\n<span style=\"color: #ff0000;\">#define<\/span> <span style=\"color: #99ccff;\">REG_READ_BIT<\/span>(reg,pos) ((reg) &amp; (1U &lt;&lt; (pos)))\r\n<span style=\"color: #ff0000;\">#define<\/span> <span style=\"color: #99ccff;\">REG_CLR_VAL<\/span>(reg,clrmask,pos) ((reg) &amp;= ~((clrmask) &lt;&lt; (pos)))\r\n<span style=\"color: #ff0000;\">#define<\/span> <span style=\"color: #99ccff;\">REG_SET_VAL<\/span>(reg,val,setmask,pos) do {\\\r\n<span style=\"color: #99ccff;\">REG_CLR_VAL<\/span>(reg,setmask,pos);\\\r\n((reg) |= ((val) &lt;&lt; (pos))); \\\r\n}while(0)\r\n\r\n<span style=\"color: #ff0000;\">#define<\/span> <span style=\"color: #99ccff;\">REG_READ_VAL<\/span>(reg,rdmask,pos) ((REG_READ(reg) &gt;&gt; (pos)) &amp; (rdmask))\r\n\r\n\r\n<span style=\"color: #ff0000;\">#endif<\/span> <span style=\"color: #339966;\">\/* REG_UTIL_H_ *\/<\/span><\/pre>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400;\">On the other hand, <\/span><b>stm32f429xx.h<\/b><span style=\"font-weight: 400;\"> is the device header file. As shown in below code, this header file contains various peripheral register structures. For instance, the peripheral register structure explains various registers of the ADC peripheral. Understanding these structures is important to configure the microcontroller&#8217;s registers accurately and efficiently.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"box-shadow: #cecece 0px 0px 0px 0px;\">#include &lt;stdint.h&gt;\r\n\r\n<span style=\"color: #339966;\">\/** @addtogroup Peripheral_registers_structures\r\n  * @{\r\n  *\/   \r\n\r\n\/** \r\n  * @brief Analog to Digital Converter  \r\n  *\/<\/span>\r\n\r\n<span style=\"color: #993366;\">typedef struct<\/span>\r\n{\r\n  __IO uint32_t SR;     <span style=\"color: #339966;\">\/*!&lt; ADC status register,                         Address offset: 0x00 *\/<\/span>\r\n  __IO uint32_t CR1;    <span style=\"color: #339966;\">\/*!&lt; ADC control register 1,                      Address offset: 0x04 *\/<\/span>\r\n  __IO uint32_t CR2;    <span style=\"color: #339966;\">\/*!&lt; ADC control register 2,                      Address offset: 0x08 *\/<\/span>\r\n  __IO uint32_t SMPR1;  <span style=\"color: #339966;\">\/*!&lt; ADC sample time register 1,                  Address offset: 0x0C *\/<\/span>\r\n  __IO uint32_t SMPR2;  <span style=\"color: #339966;\">\/*!&lt; ADC sample time register 2,                  Address offset: 0x10 *\/<\/span>\r\n  __IO uint32_t JOFR1;  <span style=\"color: #339966;\">\/*!&lt; ADC injected channel data offset register 1, Address offset: 0x14 *\/<\/span>\r\n  __IO uint32_t JOFR2;  <span style=\"color: #339966;\">\/*!&lt; ADC injected channel data offset register 2, Address offset: 0x18 *\/<\/span>\r\n  __IO uint32_t JOFR3;  <span style=\"color: #339966;\">\/*!&lt; ADC injected channel data offset register 3, Address offset: 0x1C *\/<\/span>\r\n  __IO uint32_t JOFR4;  <span style=\"color: #339966;\">\/*!&lt; ADC injected channel data offset register 4, Address offset: 0x20 *\/<\/span>\r\n  __IO uint32_t HTR;    <span style=\"color: #339966;\">\/*!&lt; ADC watchdog higher threshold register,      Address offset: 0x24 *\/<\/span>\r\n  __IO uint32_t LTR;    <span style=\"color: #339966;\">\/*!&lt; ADC watchdog lower threshold register,       Address offset: 0x28 *\/<\/span>\r\n  __IO uint32_t SQR1;   <span style=\"color: #339966;\">\/*!&lt; ADC regular sequence register 1,             Address offset: 0x2C *\/<\/span>\r\n  __IO uint32_t SQR2;  <span style=\"color: #339966;\"> \/*!&lt; ADC regular sequence register 2,             Address offset: 0x30 *\/<\/span>\r\n  __IO uint32_t SQR3;   <span style=\"color: #339966;\">\/*!&lt; ADC regular sequence register 3,             Address offset: 0x34 *\/<\/span>\r\n  __IO uint32_t JSQR;   <span style=\"color: #339966;\">\/*!&lt; ADC injected sequence register,              Address offset: 0x38*\/<\/span>\r\n  __IO uint32_t JDR1;   <span style=\"color: #339966;\">\/*!&lt; ADC injected data register 1,                Address offset: 0x3C *\/<\/span>\r\n  __IO uint32_t JDR2;   <span style=\"color: #339966;\">\/*!&lt; ADC injected data register 2,                Address offset: 0x40 *\/<\/span>\r\n  __IO uint32_t JDR3;   <span style=\"color: #339966;\">\/*!&lt; ADC injected data register 3,                Address offset: 0x44 *\/<\/span>\r\n  __IO uint32_t JDR4;   <span style=\"color: #339966;\">\/*!&lt; ADC injected data register 4,                Address offset: 0x48 *\/<\/span>\r\n  __IO uint32_t DR;     <span style=\"color: #339966;\">\/*!&lt; ADC regular data register,                   Address offset: 0x4C *\/<\/span>\r\n} ADC_TypeDef;\r\n\r\n<span style=\"color: #993366;\">typedef struct<\/span>\r\n{\r\n  __IO uint32_t CSR;    <span style=\"color: #339966;\">\/*!&lt; ADC Common status register,                  Address offset: ADC1 base address + 0x300 *\/<\/span>\r\n  __IO uint32_t CCR;   <span style=\"color: #339966;\"> \/*!&lt; ADC common control register,                 Address offset: ADC1 base address + 0x304 *\/<\/span>\r\n  __IO uint32_t CDR;    <span style=\"color: #339966;\">\/*!&lt; ADC common regular data register for dual\r\n                             AND triple modes,                            Address offset: ADC1 base address + 0x308 *\/<\/span>\r\n} ADC_Common_TypeDef;<\/pre>\n<p data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-family: 'Roboto Slab'; font-weight: 400; line-height: 30px; font-size: 17px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400;\">Moreover, <\/span><b>stm32f429xx.h<\/b><span style=\"font-weight: 400;\"> contains various base addresses of various blocks of the microcontroller. These addresses are crucial in configuring the microcontroller&#8217;s registers. Below code snippets show the base addresses for various blocks of the microcontroller.<\/span><\/p>\n<p class=\"\" style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400;\">For instance, if we want to configure the Timer2 peripheral, its registers start from APB1PERIPH_BASE + 0x0000UL base. This is the base address of the registers of the Timer2 peripheral. Understanding these base addresses is essential in configuring the microcontroller&#8217;s registers accurately.<\/span><\/p>\n<pre class=\"\"><span style=\"color: #339966;\">\/** @addtogroup Peripheral_memory_map\r\n  * @{\r\n  *\/<\/span>\r\n<span style=\"color: #ff0000;\">#define<\/span> FLASH_BASE            0x08000000UL <span style=\"color: #339966;\">\/*!&lt; FLASH(up to 2 MB) base address in the alias region<\/span>                         <span style=\"color: #339966;\">*\/<\/span>\r\n<span style=\"color: #ff0000;\">#define<\/span> CCMDATARAM_BASE       0x10000000UL <span style=\"color: #339966;\">\/*!&lt; CCM(core coupled memory) data RAM(64 KB) base address in the alias region  *\/<\/span>\r\n<span style=\"color: #ff0000;\">#define<\/span> SRAM1_BASE            0x20000000UL <span style=\"color: #339966;\">\/*!&lt; SRAM1(112 KB) base address in the alias region                              *\/<\/span>\r\n<span style=\"color: #ff0000;\">#define<\/span> SRAM2_BASE            0x2001C000UL <span style=\"color: #339966;\">\/*!&lt; SRAM2(16 KB) base address in the alias region                              *\/<\/span>\r\n<span style=\"color: #ff0000;\">#define<\/span> SRAM3_BASE            0x20020000UL <span style=\"color: #339966;\">\/*!&lt; SRAM3(64 KB) base address in the alias region                              *\/<\/span>\r\n<span style=\"color: #ff0000;\">#define<\/span> PERIPH_BASE           0x40000000UL <span style=\"color: #339966;\">\/*!&lt; Peripheral base address in the alias region                                *\/<\/span>\r\n<span style=\"color: #ff0000;\">#define<\/span> BKPSRAM_BASE          0x40024000UL <span style=\"color: #339966;\">\/*!&lt; Backup SRAM(4 KB) base address in the alias region                         *\/<\/span>\r\n<span style=\"color: #ff0000;\">#define<\/span> FMC_R_BASE            0xA0000000UL <span style=\"color: #339966;\">\/*!&lt; FMC registers base address                                                 *\/<\/span>\r\n<span style=\"color: #ff0000;\">#define<\/span> SRAM1_BB_BASE         0x22000000UL <span style=\"color: #339966;\">\/*!&lt; SRAM1(112 KB) base address in the bit-band region                          *\/<\/span>\r\n<span style=\"color: #ff0000;\">#define<\/span> SRAM2_BB_BASE         0x22380000UL <span style=\"color: #339966;\">\/*!&lt; SRAM2(16 KB) base address in the bit-band region                           *\/<\/span>\r\n<span style=\"color: #ff0000;\">#define<\/span> SRAM3_BB_BASE         0x22400000UL <span style=\"color: #339966;\">\/*!&lt; SRAM3(64 KB) base address in the bit-band region                           *\/<\/span>\r\n<span style=\"color: #ff0000;\">#define<\/span> PERIPH_BB_BASE        0x42000000UL <span style=\"color: #339966;\">\/*!&lt; Peripheral base address in the bit-band region                             *\/<\/span>\r\n<span style=\"color: #ff0000;\">#define<\/span> BKPSRAM_BB_BASE       0x42480000UL<span style=\"color: #339966;\"> \/*!&lt; Backup SRAM(4 KB) base address in the bit-band region            <\/span>          <span style=\"color: #339966;\">*\/<\/span>\r\n<span style=\"color: #ff0000;\">#define<\/span> FLASH_END             0x081FFFFFUL <span style=\"color: #339966;\">\/*!&lt; FLASH end address                                               <\/span>           <span style=\"color: #339966;\">*\/<\/span>\r\n<span style=\"color: #ff0000;\">#define<\/span> FLASH_OTP_BASE        0x1FFF7800UL <span style=\"color: #339966;\">\/*!&lt; Base address of : (up to 528 Bytes) embedded FLASH OTP Area                *\/<\/span>\r\n<span style=\"color: #ff0000;\">#define<\/span> FLASH_OTP_END         0x1FFF7A0FUL <span style=\"color: #339966;\">\/*!&lt; End address of : (up to 528 Bytes) embedded FLASH OTP Area                 *\/<\/span>\r\n<span style=\"color: #ff0000;\">#define<\/span> CCMDATARAM_END        0x1000FFFFUL <span style=\"color: #339966;\">\/*!&lt; CCM data RAM end address                                                   *\/<\/span>\r\n\r\n<span style=\"color: #339966;\">\/* Legacy defines *\/<\/span>\r\n<span style=\"color: #ff0000;\">#define<\/span> SRAM_BASE             SRAM1_BASE\r\n<span style=\"color: #ff0000;\">#define<\/span> SRAM_BB_BASE          SRAM1_BB_BASE\r\n\r\n<span style=\"color: #339966;\">\/*!&lt; Peripheral memory map *\/\r\n<\/span><span style=\"color: #ff0000;\">#define<\/span> APB1PERIPH_BASE       PERIPH_BASE\r\n<span style=\"color: #ff0000;\">#define<\/span> APB2PERIPH_BASE       (PERIPH_BASE + 0x00010000UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> AHB1PERIPH_BASE       (PERIPH_BASE + 0x00020000UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> AHB2PERIPH_BASE       (PERIPH_BASE + 0x10000000UL)\r\n\r\n<span style=\"color: #339966;\">\/*!&lt; APB1 peripherals *\/<\/span>\r\n<span style=\"color: #ff0000;\">#define<\/span> TIM2_BASE             (APB1PERIPH_BASE + 0x0000UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> TIM3_BASE             (APB1PERIPH_BASE + 0x0400UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> TIM4_BASE             (APB1PERIPH_BASE + 0x0800UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> TIM5_BASE             (APB1PERIPH_BASE + 0x0C00UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> TIM6_BASE             (APB1PERIPH_BASE + 0x1000UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> TIM7_BASE             (APB1PERIPH_BASE + 0x1400UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> TIM12_BASE            (APB1PERIPH_BASE + 0x1800UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> TIM13_BASE            (APB1PERIPH_BASE + 0x1C00UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> TIM14_BASE            (APB1PERIPH_BASE + 0x2000UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> RTC_BASE              (APB1PERIPH_BASE + 0x2800UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> WWDG_BASE             (APB1PERIPH_BASE + 0x2C00UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> IWDG_BASE             (APB1PERIPH_BASE + 0x3000UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> I2S2ext_BASE          (APB1PERIPH_BASE + 0x3400UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> SPI2_BASE             (APB1PERIPH_BASE + 0x3800UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> SPI3_BASE             (APB1PERIPH_BASE + 0x3C00UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> I2S3ext_BASE          (APB1PERIPH_BASE + 0x4000UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> USART2_BASE           (APB1PERIPH_BASE + 0x4400UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> USART3_BASE           (APB1PERIPH_BASE + 0x4800UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> UART4_BASE            (APB1PERIPH_BASE + 0x4C00UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> UART5_BASE            (APB1PERIPH_BASE + 0x5000UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> I2C1_BASE             (APB1PERIPH_BASE + 0x5400UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> I2C2_BASE             (APB1PERIPH_BASE + 0x5800UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> I2C3_BASE             (APB1PERIPH_BASE + 0x5C00UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> CAN1_BASE             (APB1PERIPH_BASE + 0x6400UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> CAN2_BASE             (APB1PERIPH_BASE + 0x6800UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> PWR_BASE              (APB1PERIPH_BASE + 0x7000UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> DAC_BASE              (APB1PERIPH_BASE + 0x7400UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> UART7_BASE            (APB1PERIPH_BASE + 0x7800UL)\r\n<span style=\"color: #ff0000;\">#define<\/span> UART8_BASE            (APB1PERIPH_BASE + 0x7C00UL)\r\n<\/pre>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400;\">In the main program, we need to include these header files. We can use the following lines of code to include them:<\/span><\/p>\n<p class=\"\" style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><b>#include \u201cstm32f429xx.h\u201d<\/b><\/p>\n<p class=\"\" style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><b>#include \u201creg_util.h\u201d<\/b><\/p>\n<p class=\"\" style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400;\">Then, we will write one function called <\/span><b>SystemClock_Setup()<\/b><span style=\"font-weight: 400;\">. This function is responsible for setting up the main PLL.<\/span><\/p>\n<p class=\"\" style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400;\">To do that, we need to access the RCC peripheral of the microcontroller. We can create a variable to access the RCC peripheral of the microcontroller. So, we need to access the registers of the RCC block. The base address of the RCC registers is available in the device header file. We can create a variable of the RCC structure <\/span><b>RCC_typedef<\/b><span style=\"font-weight: 400;\">, which we will call <\/span><b>pRCC<\/b><span style=\"font-weight: 400;\"> and this is equal to the <\/span><b>RCC_BASE<\/b><span style=\"font-weight: 400;\"> address. We can define it like this:<\/span><\/p>\n<p class=\"\" style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><b>RCC_TypeDef&nbsp; *pRCC = RCC;<\/b><\/p>\n<p class=\"\" style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400;\">Once we have the <\/span><b>pRCC<\/b><span style=\"font-weight: 400;\"> pointer, we can set the value of PLLM. To do that, we have to access the <\/span><b>RCC_PLLCFGR<\/b><span style=\"font-weight: 400;\"> register, as shown in Figure 6. This is one of the registers of the RCC block. We have to configure the value of PLLM here by writing a new value to this register. Before doing that, we need to make sure that the PLLM bits are cleared first. This is important to avoid any unwanted values from previous configurations. To do that, we can use a macro called <\/span><b>REG_SET_VAL<\/b><span style=\"font-weight: 400;\">, which takes the register value, a new value, a mask, and the position. The mask value is important as it helps clear the bits before setting a new value. The position value is the starting bit position of the value we want to set.<\/span><\/p>\n<p class=\"\" style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400;\">We can use the following line of code to set the value of PLLM with a value of 8:<\/span><\/p>\n<p class=\"\" style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><b>REG_SET_VAL(pRCC-&gt;PLLCFGR, 0x8U, 0x3FU, 0U);<\/b><\/p>\n<figure id=\"attachment_14436\" aria-describedby=\"caption-attachment-14436\" style=\"width: 727px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-14436\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/04\/Figure-5-3.png\" alt=\"Setting up main system clock code implementation\" width=\"727\" height=\"385\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/04\/Figure-5-3.png 1623w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/04\/Figure-5-3-300x159.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/04\/Figure-5-3-1024x542.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/04\/Figure-5-3-768x406.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/04\/Figure-5-3-600x318.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/04\/Figure-5-3-1536x813.png 1536w\" sizes=\"(max-width: 727px) 100vw, 727px\" \/><figcaption id=\"caption-attachment-14436\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 1. main.c file<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400;\">This line of code clears the register from the starting bit position using the mask value and sets the new value 0x8.<\/span><\/p>\n<figure id=\"attachment_14437\" aria-describedby=\"caption-attachment-14437\" style=\"width: 729px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-14437\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/04\/Figure-6-4.png\" alt=\"Setting up main system clock code implementation\" width=\"729\" height=\"407\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/04\/Figure-6-4.png 1383w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/04\/Figure-6-4-300x168.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/04\/Figure-6-4-1024x572.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/04\/Figure-6-4-768x429.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/04\/Figure-6-4-600x335.png 600w\" sizes=\"(max-width: 729px) 100vw, 729px\" \/><figcaption id=\"caption-attachment-14437\" class=\"wp-caption-text\">Figure 2. RCC PLL configuration register<\/figcaption><\/figure>\n<p class=\"\" style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400;\">Like that, we can write the rest of the code for PLL_N and PLL_P configuration. Configuring the PLL is essential in setting up the main clock, and it is just one part of a much more comprehensive process.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 20px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000080;\"><a style=\"color: #000080;\" href=\"https:\/\/www.st.com\/resource\/en\/reference_manual\/dm00031020-stm32f405-415-stm32f407-417-stm32f427-437-and-stm32f429-439-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf\"><b>Reference manual<\/b><\/a><\/span><\/p>\n<p class=\"\" style=\"font-size: 18px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #800080;\"><b>Get the Full Course on STM32-LTDC, LCD-TFT, LVGL (MCU3)<\/b><\/span><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/www.udemy.com\/course\/mastering-microcontroller-stm32-ltdc-lcd-tft-lvgl\/\"> <b>Here.<\/b><\/a><\/span><\/p>\n<p class=\"\" style=\"font-size: 20px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000080;\"><b>FastBit Embedded Brain Academy Courses<\/b><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">Click here:&nbsp;<span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/fastbitlab.com\/course1\" target=\"_blank\" rel=\"noopener\">https:\/\/fastbitlab.com\/course1<\/a><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<\/div>\n<div class=\"col-lg-1 col-md-12 col-sm-12 col-xs-12\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Setting up main system clock code implementation part-1 &nbsp; In this article, we will begin creating the main clock code for our application. Having an accurate clock is essential for many applications and devices, and it&#8217;s no different in our case. The timekeeping module of our application is the backbone of the system, and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":14432,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"0","ocean_second_sidebar":"0","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"0","ocean_custom_header_template":"0","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"0","ocean_menu_typo_font_family":"0","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"enable","ocean_disable_heading":"default","ocean_post_title":"Setting up main system clock code implementation part-1","ocean_post_subheading":"","ocean_post_title_style":"solid-color","ocean_post_title_background_color":"#0d64bc","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"off","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"0","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"off","ocean_gallery_id":[],"footnotes":""},"categories":[8],"tags":[],"class_list":["post-14428","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","entry","has-media"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Setting Up Main System Clock code: Implementation Guide (Part 1)<\/title>\n<meta name=\"description\" content=\"Learn how to implement the main system clock code for your application, ensuring accurate timekeeping using STM32 microcontroller&#039;s register\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Setting Up Main System Clock code: Implementation Guide (Part 1)\" \/>\n<meta property=\"og:description\" content=\"Learn how to implement the main system clock code for your application, ensuring accurate timekeeping using STM32 microcontroller&#039;s register\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\/\" \/>\n<meta property=\"og:site_name\" content=\"FastBit EBA\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/fastbiteba\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-04-19T05:03:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-07T07:12:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/04\/Figure-1-7.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1585\" \/>\n\t<meta property=\"og:image:height\" content=\"777\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"FastBitLab\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:site\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"FastBitLab\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"STM32-LTDC, LCD-TFT, LVGL (MCU3) Lecture 17| Setting up main system clock code implementation part-1\",\"datePublished\":\"2023-04-19T05:03:42+00:00\",\"dateModified\":\"2023-09-07T07:12:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\\\/\"},\"wordCount\":712,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/Figure-1-7.png\",\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\\\/\",\"name\":\"Setting Up Main System Clock code: Implementation Guide (Part 1)\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/Figure-1-7.png\",\"datePublished\":\"2023-04-19T05:03:42+00:00\",\"dateModified\":\"2023-09-07T07:12:53+00:00\",\"description\":\"Learn how to implement the main system clock code for your application, ensuring accurate timekeeping using STM32 microcontroller's register\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/Figure-1-7.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/Figure-1-7.png\",\"width\":1585,\"height\":777,\"caption\":\"Figure 1. Header file\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"STM32-LTDC, LCD-TFT, LVGL (MCU3) Lecture 17| Setting up main system clock code implementation part-1\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"name\":\"FastBit EBA\",\"description\":\"Your Online Academy of Embedded Systems\",\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\",\"name\":\"FastBit EBA\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"width\":640,\"height\":640,\"caption\":\"FastBit EBA\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/fastbiteba\\\/\",\"https:\\\/\\\/x.com\\\/fastbiteba\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/fastbit-embedded-brain-academy-b3167b124\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCa1REBV9hyrzGp2mjJCagBg\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\",\"name\":\"FastBitLab\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"caption\":\"FastBitLab\"},\"description\":\"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Setting Up Main System Clock code: Implementation Guide (Part 1)","description":"Learn how to implement the main system clock code for your application, ensuring accurate timekeeping using STM32 microcontroller's register","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\/","og_locale":"en_US","og_type":"article","og_title":"Setting Up Main System Clock code: Implementation Guide (Part 1)","og_description":"Learn how to implement the main system clock code for your application, ensuring accurate timekeeping using STM32 microcontroller's register","og_url":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2023-04-19T05:03:42+00:00","article_modified_time":"2023-09-07T07:12:53+00:00","og_image":[{"width":1585,"height":777,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/04\/Figure-1-7.png","type":"image\/png"}],"author":"FastBitLab","twitter_card":"summary_large_image","twitter_creator":"@fastbiteba","twitter_site":"@fastbiteba","twitter_misc":{"Written by":"FastBitLab","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"STM32-LTDC, LCD-TFT, LVGL (MCU3) Lecture 17| Setting up main system clock code implementation part-1","datePublished":"2023-04-19T05:03:42+00:00","dateModified":"2023-09-07T07:12:53+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\/"},"wordCount":712,"commentCount":0,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/04\/Figure-1-7.png","articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\/","url":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\/","name":"Setting Up Main System Clock code: Implementation Guide (Part 1)","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/04\/Figure-1-7.png","datePublished":"2023-04-19T05:03:42+00:00","dateModified":"2023-09-07T07:12:53+00:00","description":"Learn how to implement the main system clock code for your application, ensuring accurate timekeeping using STM32 microcontroller's register","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/04\/Figure-1-7.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/04\/Figure-1-7.png","width":1585,"height":777,"caption":"Figure 1. Header file"},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-17-setting-up-main-system-clock-code-implementation-part-1\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fastbitlab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"STM32-LTDC, LCD-TFT, LVGL (MCU3) Lecture 17| Setting up main system clock code implementation part-1"}]},{"@type":"WebSite","@id":"https:\/\/fastbitlab.com\/blog\/#website","url":"https:\/\/fastbitlab.com\/blog\/","name":"FastBit EBA","description":"Your Online Academy of Embedded Systems","publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fastbitlab.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fastbitlab.com\/blog\/#organization","name":"FastBit EBA","url":"https:\/\/fastbitlab.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","width":640,"height":640,"caption":"FastBit EBA"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/fastbiteba\/","https:\/\/x.com\/fastbiteba","https:\/\/www.linkedin.com\/in\/fastbit-embedded-brain-academy-b3167b124\/","https:\/\/www.youtube.com\/channel\/UCa1REBV9hyrzGp2mjJCagBg"]},{"@type":"Person","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d","name":"FastBitLab","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","caption":"FastBitLab"},"description":"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries."}]}},"_links":{"self":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/14428","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/comments?post=14428"}],"version-history":[{"count":5,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/14428\/revisions"}],"predecessor-version":[{"id":15849,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/14428\/revisions\/15849"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/14432"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=14428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=14428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=14428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}