{"id":14608,"date":"2023-05-09T10:23:49","date_gmt":"2023-05-09T04:53:49","guid":{"rendered":"https:\/\/fastbitlab.com\/?p=14608"},"modified":"2023-08-17T10:35:44","modified_gmt":"2023-08-17T05:05:44","slug":"stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\/","title":{"rendered":"STM32-LTDC, LCD-TFT, LVGL (MCU3) Lecture 25| LCD SPI initialization coding part-2"},"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-9 col-md-12 col-xs-12 col-sm-12\">\n<p class=\"\">&nbsp;<\/p>\n<h1 class=\"\" style=\"text-align: center; font-size: 33px; line-height: 48px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><strong><span style=\"color: #000080;\">LCD SPI initialization coding part-2<\/span><\/strong><\/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-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; color: #000000;\">We defined all the required LCD signals for our exercise.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"box-shadow: #cecece 0px 0px 0px 0px inset;\"><span style=\"color: #993366;\">#include<\/span> \"stm32f429xx.c\"\r\n\r\n<span style=\"color: #008000;\">\/*Define all the LCD signals *\/<\/span>\r\n\r\n<span style=\"color: #993366;\">#ifdef<\/span> STM32F429I_DISC1\r\n\r\n  &nbsp;<span style=\"color: #993366;\"> #define<\/span> SPI&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SPI5\r\n\r\n  &nbsp;<span style=\"color: #993366;\"> #define<\/span> LCD_SCL_PIN&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GPIO_PIN_7\r\n\r\n  &nbsp; <span style=\"color: #993366;\">#define<\/span> LCD_SCL_PORT&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIOF\r\n\r\n  &nbsp; <span style=\"color: #993366;\">#define<\/span> LCD_SDA_PIN&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GPIO_PIN_9\r\n\r\n  &nbsp; <span style=\"color: #993366;\">#define<\/span> LCD_SDA_PORT&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIOF\r\n\r\n  &nbsp; <span style=\"color: #993366;\">#define<\/span> LCD_RESX_PIN&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIO_PIN_7\r\n\r\n  &nbsp; <span style=\"color: #993366;\">#define<\/span> LCD_RESX_PORT&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GPIOA\r\n\r\n  &nbsp; <span style=\"color: #993366;\">#define<\/span> LCD_CSX_PIN&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GPIO_PIN_2\r\n\r\n  &nbsp; <span style=\"color: #993366;\">#define<\/span> LCD_CSX_PORT&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIOC\r\n\r\n  &nbsp;<span style=\"color: #993366;\"> #define<\/span> LCD_DCX_PIN&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GPIO_PIN_13\r\n\r\n  <span style=\"color: #993366;\">&nbsp; #define<\/span> LCD_DCX_PORT&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIOD\r\n\r\n<span style=\"color: #993366;\">#elif<\/span> defined(STM32F407)\r\n\r\n  &nbsp; <span style=\"color: #993366;\">#define<\/span> SPI&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SPI2\r\n\r\n  &nbsp;<span style=\"color: #993366;\"> #define<\/span> LCD_SCL_PIN&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;   GPIO_PIN_13\r\n\r\n  &nbsp;<span style=\"color: #993366;\"> #define<\/span> LCD_SCL_PORT&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GPIOB\r\n\r\n  &nbsp; <span style=\"color: #993366;\">#define<\/span> LCD_SDI_PIN&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIO_PIN_15\r\n\r\n  &nbsp;<span style=\"color: #993366;\"> #define<\/span> LCD_SDI_PORT&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GPIOB\r\n\r\n  &nbsp;<span style=\"color: #993366;\"> #define<\/span> LCD_SDO_PIN&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIO_PIN_2\r\n\r\n  &nbsp; <span style=\"color: #993366;\">#define<\/span> LCD_SDO_PORT&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GPIOC\r\n\r\n  &nbsp;<span style=\"color: #993366;\"> #define<\/span> LCD_RESX_PIN&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GPIO_PIN_10\r\n\r\n  &nbsp; <span style=\"color: #993366;\">#define<\/span> LCD_RESX_PORT&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIOD\r\n\r\n  &nbsp; <span style=\"color: #993366;\">#define<\/span> LCD_CSX_PIN&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIO_PIN_11\r\n\r\n  <span style=\"color: #993366;\">&nbsp; #define<\/span> LCD_CSX_PORT&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GPIOD\r\n\r\n  &nbsp;<span style=\"color: #993366;\"> #define<\/span> LCD_DCX_PIN&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIO_PIN_9\r\n\r\n  &nbsp; <span style=\"color: #993366;\">#define<\/span> LCD_DCX_PORT&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GPIOD\r\n\r\n\r\n\r\n<span style=\"color: #993366;\">#else<\/span>\r\n\r\n  &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #993366;\">#error<\/span>\"Supported device is not selected\"\r\n\r\n<span style=\"color: #993366;\">#endif<\/span><\/pre>\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; color: #000000;\">Here, you can see that we have used different names for the DCX signal. However, there are still some differences in the SDA. In the STM32F429I_DISC1 section, we have used the name SDA, whereas, in the STM32F407, we have two names: SDI and SDO.<\/span><\/p>\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; color: #000000;\">In this article, we will implement the BSP_LCD_Init function. This function first requires us to initialize the pins. Therefore, we will need to initialize all the pins. After that, we will need to initialize the SPI. To accomplish this, we will define the SPI using the #define SPI macro, as shown above.<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; 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: #993366;\"><strong>#define SPI&nbsp; SPI5<\/strong><\/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: #993366;\"><strong>#define SPI&nbsp; SPI2<\/strong><\/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; color: #000000;\">Next, we will implement helper functions such as LCD_Pin_init(), LCD_SPI_init(), LCD_Reset(), and LCD_Config(). These functions are static and will assist in initializing the pins, and SPI, resetting the LCD and configuring it by sending commands.<\/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; color: #000000;\">Specifically, we will use LCD_Pin_init() for pin initialization, and SPI initialization. After initialization, we will reset the LCD and configure it by sending the necessary commands.<\/span><\/p>\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; color: #000000;\">First, we need to initialize the RESX, CSX, and DCX pins for the output mode. Allow me to briefly explain the steps required to configure these pins for GPIO output mode.<\/span><\/p>\n<figure id=\"attachment_14613\" aria-describedby=\"caption-attachment-14613\" style=\"width: 638px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-14613 \" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/05\/Figure-2-1.png\" alt=\"Figure 2. ILI9341 programming interface\" width=\"638\" height=\"333\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-2-1.png 1667w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-2-1-300x157.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-2-1-1024x535.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-2-1-768x401.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-2-1-600x313.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-2-1-1536x803.png 1536w\" sizes=\"(max-width: 638px) 100vw, 638px\" \/><figcaption id=\"caption-attachment-14613\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 1. ILI9341 programming interface<\/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=\"color: #000000;\"><span style=\"font-weight: 400;\">Let&#8217;s consult the <\/span><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" 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\"><span style=\"font-weight: 400;\">reference manual<\/span><\/a><\/span><span style=\"font-weight: 400;\"> to determine the necessary actions. Firstly, by examining the memory map(Figure 2), we can identify that the GPIOs are u<\/span><span style=\"font-weight: 400;\">sually connected to the AHB1 domain<\/span><span style=\"font-weight: 400;\">. Therefore,<\/span><span style=\"font-weight: 400;\"> before you configure any registers of these peripherals, you have to enable the clock for these peripherals.<\/span><\/span><\/p>\n<figure id=\"attachment_14614\" aria-describedby=\"caption-attachment-14614\" style=\"width: 678px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-14614 \" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/05\/Figure-3-1.png\" alt=\"Figure 3. Memory map\" width=\"678\" height=\"340\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-3-1.png 1747w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-3-1-300x150.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-3-1-1024x513.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-3-1-768x385.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-3-1-600x301.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-3-1-1536x769.png 1536w\" sizes=\"(max-width: 678px) 100vw, 678px\" \/><figcaption id=\"caption-attachment-14614\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. Memory map<\/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; color: #000000;\">As I am working with GPIOs, I will navigate to the AHB1 peripheral clock register (AHB1ENR).&nbsp; And here you have to turn on the clock for the peripheral which you want to use.<\/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; color: #000000;\">To do so, one must access the clock enable register found within the RCC AHB1 peripheral clock register (RCC_AHB1ENR).<\/span><\/p>\n<figure id=\"attachment_14615\" aria-describedby=\"caption-attachment-14615\" style=\"width: 637px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-14615\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/05\/Figure-4-1.png\" alt=\"LCD SPI initialization\" width=\"637\" height=\"311\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-4-1.png 1769w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-4-1-300x146.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-4-1-1024x500.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-4-1-768x375.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-4-1-600x293.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-4-1-1536x749.png 1536w\" sizes=\"(max-width: 637px) 100vw, 637px\" \/><figcaption id=\"caption-attachment-14615\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 3. RCC AHB1 peripheral clock register(RCC_AHB1ENR)<\/span><\/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; color: #000000;\">First, let&#8217;s begin with the RESX pin, which can be found on PA7, a GPIO port. Since we will be utilizing GPIO ports A, C, D, and F, it is essential to activate the clock for all these peripherals by selecting the appropriate bits from the RCC_AHB1ENR register. That&#8217;s the first thing you have to do.<\/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; color: #000000;\">Next, you must configure the RESX, CSX, and DCX pins to output mode. To do this, navigate to the GPIO section, locate the mode register, and choose the general-purpose output mode.<\/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; color: #000000;\">To summarize, start by enabling the clock for the necessary peripherals, and then configure the pins to output mode.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_14616\" aria-describedby=\"caption-attachment-14616\" style=\"width: 732px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14616\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/05\/Figure-5.png\" alt=\"LCD SPI initialization\" width=\"732\" height=\"362\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-5.png 1747w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-5-300x149.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-5-1024x507.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-5-768x380.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-5-600x297.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-5-1536x761.png 1536w\" sizes=\"(max-width: 732px) 100vw, 732px\" \/><figcaption id=\"caption-attachment-14616\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 4. GPIO port mode registers<\/span><\/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; color: #000000;\">So, just feed the appropriate value into these bit fields. You can use the REG_SET_VAL macro, which you used before.<\/span><\/p>\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; color: #000000;\">After that, we need to consider the output type. As previously mentioned, we want to use push-pull, no open drain things here. Therefore, we won&#8217;t be utilizing any external or internal pull-ups or pull-downs. Our goal is simply to control the signal&#8217;s ON and OFF states.<\/span><\/p>\n<figure id=\"attachment_14617\" aria-describedby=\"caption-attachment-14617\" style=\"width: 736px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14617\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/05\/Figure-6.png\" alt=\"LCD SPI initialization\" width=\"736\" height=\"318\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-6.png 1741w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-6-300x130.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-6-1024x443.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-6-768x332.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-6-600x260.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-6-1536x664.png 1536w\" sizes=\"(max-width: 736px) 100vw, 736px\" \/><figcaption id=\"caption-attachment-14617\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 5. GPIO port output type register<\/span><\/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; color: #000000;\">The GPIO port output speed register(GPIOx_OSPEEDR). So, it doesn&#8217;t matter actually,&nbsp; set it for high speed.&nbsp;<\/span><\/p>\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; color: #000000;\">Let&#8217;s code for one pin. The following code is related to configuring one GPIO pin.&nbsp;<\/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; color: #000000;\">First start with REX, which is PA7.This indicates that the pin being configured is PA7. PA7 is a specific pin on the microcontroller that is being programmed.<\/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; color: #000000;\">Before this will just turn on the clock. So, before configuring the pin, the clock needs to be enabled for the GPIO port to which the pin belongs. This is necessary for the pin to function correctly.<\/span><\/p>\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; color: #000000;\">Let\u2019s add the header file #include &#8220;reg_util.h&#8221;.&nbsp; This line includes the header file &#8220;reg_util.h&#8221;, which provides definitions for Register Access Macros that will be used later in the code.<\/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;\">Create one variable \u2192<\/span><span style=\"color: #993366;\"><b> RCC_TypeDef *pRCC = RCC;&nbsp;<\/b><\/span><\/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; color: #000000;\">Here creates a pointer variable named &#8220;pRCC&#8221; that points to the RCC (Reset and Clock Control) register in the microcontroller. This register controls the clock system for various peripherals, including GPIO ports.<\/span><\/p>\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=\"color: #993366;\"><b>REG_SET_BIT(pRCC-&gt;AHB1ENR, RCC_AHB1ENR_GPIOAEN_Pos);<\/b><\/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; color: #000000;\">This line uses the Register Access Macro REG_SET_BIT to set a particular bit in the AHB1ENR (Advanced High-performance Bus 1 Enable Register) of the RCC register. This bit corresponds to the GPIOA port, which is the port to which the PA7 pin belongs. Setting this bit enables the clock for the GPIOA port.<\/span><\/p>\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; color: #000000;\">The similar steps need to be followed to enable the clock for the GPIOC and GPIOD ports. The exact code for this is not shown, but it likely involves using the same Register Access Macro to set the appropriate bit in the AHB1ENR register for those ports.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"box-shadow: #cecece 0px 0px 0px 0px inset;\"><span style=\"color: #993366;\">void<\/span> LCD_Pin_Init(<span style=\"color: #993366;\">void<\/span>)\r\n{\r\n<span style=\"color: #008000;\">RCC_TypeDef<\/span> *pRCC = RCC;\r\n<span style=\"color: #008000;\">GPIO_TypeDef<\/span> *pGPIOA = GPIOA;\r\n\r\n\r\n<span style=\"color: #008000;\">\/* Enable the clock for GPIOA,C,D peripherals *\/<\/span>\r\nREG_SET_BIT(pRCC-&gt;<span style=\"color: #99ccff;\">AHB1ENR<\/span>,RCC_AHB1ENR_GPIOAEN_Pos);\r\nREG_SET_BIT(pRCC-&gt;<span style=\"color: #99ccff;\">AHB1ENR<\/span>,RCC_AHB1ENR_GPIOCEN_Pos);\r\nREG_SET_BIT(pRCC-&gt;<span style=\"color: #99ccff;\">AHB1ENR<\/span>,RCC_AHB1ENR_GPIODEN_Pos);\r\n\r\n\r\n<span style=\"color: #008000;\">\/\/REX<\/span>\r\nREG_SET_VAL(pGPIOA-&gt;<span style=\"color: #99ccff;\">MODER<\/span>,0x1U,0x3,GPIO_MODER_MODE7_Pos); <span style=\"color: #008000;\">\/*mode*\/<\/span>\r\nREG_CLR_BIT(pGPIOA-&gt;<span style=\"color: #99ccff;\">OTYPER<\/span>,GPIO_OTYPER_OT7_Pos); <span style=\"color: #008000;\">\/*Output type*\/<\/span>\r\nREG_SET_VAL(pGPIOA-&gt;<span style=\"color: #99ccff;\">OSPEED<\/span>R,2U,0x3U,GPIO_OSPEEDR_OSPEED7_Pos);<span style=\"color: #008000;\"> \/*speed*\/<\/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; color: #000000;\">After identifying the target register, REG_SET_VAL can be used. Before that, which specific register are you trying to modify?<\/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; color: #000000;\">Let&#8217;s focus on programming the registers of the GPIOA peripheral. To do so, we need to create a variable that can access the base address of the peripheral. This can be achieved by defining a pointer variable of type GPIO_TypeDef, which we can name as pGPIOA, and assigning it the value of the GPIOA base address.<\/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: #993366;\"><b>GPIO_TypeDef&nbsp; *pGPIOA = GPIOA; <\/b><span style=\"font-weight: 400;\">&nbsp;&nbsp;<\/span><\/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; color: #000000;\">Going forward, we need to use this pGPIOA pointer to access the specific registers of GPIOA that we want to modify.<\/span><\/p>\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; color: #000000;\">The first register we want to set is the mode register MODER(Figure 4). The value we want to set in this register is 01, which corresponds to the binary value 0x1U. To set this value, we need to use a mask of 0x3, which will only modify the relevant bits in the register.<\/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; color: #000000;\">Since every pin in the GPIOA peripheral takes up 2 bits in the MODER register, we need to identify the correct position of the bits corresponding to the pin we want to modify. For example, for pin 7, we need to use the position GPIO_MODER_MODE7_Pos, which is equivalent to 14.<\/span><\/p>\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; color: #000000;\">To configure the mode for GPIO port A, PIN number 7, refer to Figure 5 and locate pin number 7.&nbsp;<\/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;\">Use the available macro, <\/span><span style=\"color: #993366;\"><b>REG_SET_VAL(pGPIOA-&gt;MODER, 0x1U, 0x3, GPIO_MODER_MODE7_Pos)<\/b><\/span><span style=\"font-weight: 400;\">, to set the mode.<\/span><\/span><\/p>\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; color: #000000;\">Next, choose the output type Push-pull by referring to Figure 6. Since every pin takes a single bit and it needs to be 0, simply use the clear bit by using the register pGPIOA-&gt;OTYPER and GPIO_OTYPER_OT7_Pos. Use REG_CLR_BIT to clear the bit:&nbsp;<\/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: #993366;\"><b>REG_CLR_BIT(pGPIOA-&gt;OTYPER, GPIO_OTYPER_OT7_Pos);<\/b><\/span><\/p>\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; color: #000000;\">To set the speed, use REG_SET_VAL and the register pGPIO-&gt;OSPEEDR with a value of 2. Then, (0x3). The position is available with GPIO_OSPEEDR_OSPEED7_Pos.&nbsp;<\/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;\">Use<\/span><span style=\"color: #993366;\"><b> REG_SET_VAL(pGPIOA-&gt;OSPEEDR, 2U, 0x3U, GPIO_OSPEEDR_OSPEED7_Pos)<\/b><\/span><span style=\"font-weight: 400;\"> to configure the REX pin to push-pull output.<\/span><\/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; color: #000000;\">These steps will configure the REX pin, and you can continue with the remaining pins.<\/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;\"><b>FastBit Embedded Brain Academy Courses<\/b><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; font-family: 'Roboto Slab'; font-weight: 400;\" 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>&nbsp;<\/p>\n<\/div>\n<div class=\"col-lg-2 col-md-12 col-sm-12 col-xs-12\">\n<p>&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; LCD SPI initialization coding part-2 &nbsp; We defined all the required LCD signals for our exercise. #include &#8220;stm32f429xx.c&#8221; \/*Define all the LCD signals *\/ #ifdef STM32F429I_DISC1 &nbsp; #define SPI&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SPI5 &nbsp; #define LCD_SCL_PIN&nbsp; &nbsp; &nbsp; &nbsp; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":14613,"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":"LCD SPI initialization coding part-2","ocean_post_subheading":"","ocean_post_title_style":"solid-color","ocean_post_title_background_color":"#004d91","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-14608","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>LCD SPI Initialization and Pin Configuration: Coding Part 2<\/title>\n<meta name=\"description\" content=\"LCD SPI Initialization- In this tutorial, learn how to configure and initialize GPIO pins for SPI communication in STM32 microcontrollers to\" \/>\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-25-lcd-spi-initialization-coding-part-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"LCD SPI Initialization and Pin Configuration: Coding Part 2\" \/>\n<meta property=\"og:description\" content=\"LCD SPI Initialization- In this tutorial, learn how to configure and initialize GPIO pins for SPI communication in STM32 microcontrollers to\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\/\" \/>\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-05-09T04:53:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-17T05:05:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-2-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1667\" \/>\n\t<meta property=\"og:image:height\" content=\"871\" \/>\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=\"6 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-25-lcd-spi-initialization-coding-part-2\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"STM32-LTDC, LCD-TFT, LVGL (MCU3) Lecture 25| LCD SPI initialization coding part-2\",\"datePublished\":\"2023-05-09T04:53:49+00:00\",\"dateModified\":\"2023-08-17T05:05:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\\\/\"},\"wordCount\":1283,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/Figure-2-1.png\",\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\\\/\",\"name\":\"LCD SPI Initialization and Pin Configuration: Coding Part 2\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/Figure-2-1.png\",\"datePublished\":\"2023-05-09T04:53:49+00:00\",\"dateModified\":\"2023-08-17T05:05:44+00:00\",\"description\":\"LCD SPI Initialization- In this tutorial, learn how to configure and initialize GPIO pins for SPI communication in STM32 microcontrollers to\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/Figure-2-1.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/Figure-2-1.png\",\"width\":1667,\"height\":871,\"caption\":\"Figure 2. ILI9341 programming interface\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\\\/#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 25| LCD SPI initialization coding part-2\"}]},{\"@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":"LCD SPI Initialization and Pin Configuration: Coding Part 2","description":"LCD SPI Initialization- In this tutorial, learn how to configure and initialize GPIO pins for SPI communication in STM32 microcontrollers to","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-25-lcd-spi-initialization-coding-part-2\/","og_locale":"en_US","og_type":"article","og_title":"LCD SPI Initialization and Pin Configuration: Coding Part 2","og_description":"LCD SPI Initialization- In this tutorial, learn how to configure and initialize GPIO pins for SPI communication in STM32 microcontrollers to","og_url":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2023-05-09T04:53:49+00:00","article_modified_time":"2023-08-17T05:05:44+00:00","og_image":[{"width":1667,"height":871,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-2-1.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":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"STM32-LTDC, LCD-TFT, LVGL (MCU3) Lecture 25| LCD SPI initialization coding part-2","datePublished":"2023-05-09T04:53:49+00:00","dateModified":"2023-08-17T05:05:44+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\/"},"wordCount":1283,"commentCount":0,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-2-1.png","articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\/","url":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\/","name":"LCD SPI Initialization and Pin Configuration: Coding Part 2","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-2-1.png","datePublished":"2023-05-09T04:53:49+00:00","dateModified":"2023-08-17T05:05:44+00:00","description":"LCD SPI Initialization- In this tutorial, learn how to configure and initialize GPIO pins for SPI communication in STM32 microcontrollers to","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-2-1.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-2-1.png","width":1667,"height":871,"caption":"Figure 2. ILI9341 programming interface"},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvgl-mcu3-lecture-25-lcd-spi-initialization-coding-part-2\/#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 25| LCD SPI initialization coding part-2"}]},{"@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\/14608","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=14608"}],"version-history":[{"count":4,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/14608\/revisions"}],"predecessor-version":[{"id":15191,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/14608\/revisions\/15191"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/14613"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=14608"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=14608"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=14608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}