{"id":14725,"date":"2023-05-20T09:40:49","date_gmt":"2023-05-20T04:10:49","guid":{"rendered":"https:\/\/fastbitlab.com\/?p=14725"},"modified":"2023-06-30T16:44:46","modified_gmt":"2023-06-30T11:14:46","slug":"stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\/","title":{"rendered":"STM32-LTDC, LCD-TFT, LVGL(MCU3) Lecture 30| ILI9341 TFT-LCD Initialization commands"},"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<h2 style=\"text-align: center; font-family: 'Roboto Slab'; font-weight: 400; font-size: 35px; line-height: 50px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"color: #000080;\"><b>ILI9341 TFT-LCD Initialization commands<\/b><\/span><\/h2>\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;\">In this article, let\u2019s understand the significance of the RESX, CSX, and DCX pins.<\/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;\">You can find RESX, CSX, D\/CX signals in the <\/span><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/cdn-shop.adafruit.com\/datasheets\/ILI9341.pdf\"><span style=\"font-weight: 400;\">datasheet of the ILI9341 chip<\/span><\/a><\/span><span style=\"font-weight: 400;\">.&nbsp; You can see Figure 1, these 3 signals are inputs to the chip.<\/span><\/span><\/p>\n<figure id=\"attachment_14728\" aria-describedby=\"caption-attachment-14728\" style=\"width: 631px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-14728 \" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/05\/Figure-1-6.png\" alt=\"Figure 1. RESX, CSX,D\/CX pins\" width=\"631\" height=\"303\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-1-6.png 1835w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-1-6-300x144.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-1-6-1024x492.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-1-6-768x369.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-1-6-600x288.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-1-6-1536x737.png 1536w\" sizes=\"(max-width: 631px) 100vw, 631px\" \/><figcaption id=\"caption-attachment-14728\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 1. RESX, CSX,D\/CX pins<\/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;\">All the pin descriptions you can see <\/span><span style=\"font-weight: 400;\">in the <\/span><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/cdn-shop.adafruit.com\/datasheets\/ILI9341.pdf\"><span style=\"font-weight: 400;\">datasheet of the ILI9341 chip<\/span><\/a><\/span><span style=\"font-weight: 400;\">.<\/span><\/span><\/p>\n<figure id=\"attachment_14729\" aria-describedby=\"caption-attachment-14729\" style=\"width: 681px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-14729\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/05\/Figure-2-6.png\" alt=\"ILI9341 TFT-LCD Initialization commands \" width=\"681\" height=\"386\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-2-6.png 1659w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-2-6-300x170.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-2-6-1024x581.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-2-6-768x436.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-2-6-600x340.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-2-6-1536x871.png 1536w\" sizes=\"(max-width: 681px) 100vw, 681px\" \/><figcaption id=\"caption-attachment-14729\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. Pin descriptions<\/span><\/figcaption><\/figure>\n<p style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 20px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"text-decoration: underline; color: #000080;\"><b>RESX<\/b><\/span><\/p>\n<ul 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=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">This signal will reset the device and must be applied to properly initialize the chip.&nbsp;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Signal is active low<\/span><\/li>\n<\/ul>\n<p style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 20px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"text-decoration: underline; color: #000080;\"><span style=\"text-decoration: underline;\"><b>CSX<\/b><\/span><\/span><\/p>\n<ul 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=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Chip select input pin \u201cLow enable\u201d.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">This pin can be permanently fixed \u201cLow\u201d in MPU interface mode only.&nbsp;<\/span><\/li>\n<\/ul>\n<p style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 20px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"text-decoration: underline; color: #000080;\"><span style=\"text-decoration: underline;\"><b>D\/CX<\/b><\/span><\/span><\/p>\n<ul 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=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">8080 &#8211; I \/ 8080- II system(WRX): Serves as a write signal and writes data at the rising edge<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">4 line system (D\/CX): Serves as command or parameter select.<\/span><\/li>\n<\/ul>\n<p>&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 a 4-line system, specifically our SPI system, the D\/CX pin functions as a command or parameter selector. When the D\/CX pin is set to 0, any incoming data over the SDA line is treated as a command. On the other hand, if the D\/CX pin is set to 1, the incoming data is treated as a parameter.&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;\">This is the fundamental purpose of these three pins.<\/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 set the initial state for the CSX, RESX, and D\/CX signals. Keep the initial state of these three signals as high.&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;\">To do this, we can use the REG_SET_BIT function and select pGPIOC and the ODR register. The ODR register allows us to change the output status of a pin, setting it either high or low. If we set the pin state to high using the ODR register, the CSX signal will become high.<\/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;\">Similarly, we need to set the initial state for the RESX and D\/CX signals as shown in Figure 3. To achieve this, we can follow the same procedure by using the REG_SET_BIT function to select the appropriate GPIO and ODR register.<\/span><\/p>\n<figure id=\"attachment_14730\" aria-describedby=\"caption-attachment-14730\" style=\"width: 718px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-14730\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/05\/Figure-3-6.png\" alt=\"ILI9341 TFT-LCD Initialization commands \" width=\"718\" height=\"423\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-3-6.png 1097w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-3-6-300x177.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-3-6-1024x604.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-3-6-768x453.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-3-6-600x354.png 600w\" sizes=\"(max-width: 718px) 100vw, 718px\" \/><figcaption id=\"caption-attachment-14730\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 3. code<\/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;\">If you want to explore the ODR register, you can navigate to the GPIO section, where you&#8217;ll find the registers and specifically the ODR (output data register).<\/span><\/p>\n<figure id=\"attachment_14731\" aria-describedby=\"caption-attachment-14731\" style=\"width: 644px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14731\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/05\/Figure-4-6.png\" alt=\"ILI9341 TFT-LCD Initialization commands \" width=\"644\" height=\"244\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-4-6.png 1749w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-4-6-300x114.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-4-6-1024x388.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-4-6-768x291.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-4-6-600x227.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-4-6-1536x582.png 1536w\" sizes=\"(max-width: 644px) 100vw, 644px\" \/><figcaption id=\"caption-attachment-14731\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 4. ODR 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;\">You can see that it is not an atomic set or reset. For atomic bitset\/reset, you can consult GPIOx_BSRR register.<\/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;\">We have made progress up to the point of configuring the SPI peripheral. Our next task is to set up the frame buffer for our application, but we will tackle that step later. For now, we need to focus on initializing the LCD module by sending LCD commands over SPI.&nbsp; <\/span><span style=\"font-weight: 400; color: #000000;\">This is necessary because the ILI9341 chip cannot be used without proper initialization. It is important to note that this step is not necessary for the STM32F746-DISC board.<\/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 begin, we will explore the ILI9341 commands. We can refer to the datasheet for detailed information. The Command List section provides a list of different commands and command codes( Figure 5).<\/span><\/p>\n<figure id=\"attachment_14732\" aria-describedby=\"caption-attachment-14732\" style=\"width: 682px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14732\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/05\/Figure-5-2.png\" alt=\"ILI9341 TFT-LCD Initialization commands \" width=\"682\" height=\"382\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-5-2.png 1683w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-5-2-300x168.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-5-2-1024x574.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-5-2-768x430.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-5-2-600x336.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-5-2-1536x861.png 1536w\" sizes=\"(max-width: 682px) 100vw, 682px\" \/><figcaption id=\"caption-attachment-14732\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 5. Commands<\/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;\">If you want to explore a specific command, a quick way to find it is by searching for its command code. For instance, if you&#8217;re looking for the command used to turn off the sleep mode of an LCD module, you can search for command code 11h, which corresponds to the Sleep Out command. This command is specifically designed to bring the module out of sleep mode and reactivate its display. By using command codes, you can easily locate the specific commands you need for your project without having to manually search through documentation or code.<\/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 see the LCD_config.&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;\">There are 2 commands here. And we have to implement this LCD_Write_Cmd.<\/span><\/p>\n<figure id=\"attachment_14733\" aria-describedby=\"caption-attachment-14733\" style=\"width: 643px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14733\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/05\/Figure-6-4.png\" alt=\"ILI9341 TFT-LCD Initialization commands \" width=\"643\" height=\"596\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-6-4.png 868w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-6-4-300x278.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-6-4-768x711.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-6-4-600x556.png 600w\" sizes=\"(max-width: 643px) 100vw, 643px\" \/><figcaption id=\"caption-attachment-14733\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 6. Code<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 20px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"text-decoration: underline; color: #000080;\"><b>LCD write command<\/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=\"color: #000000;\"><span style=\"font-weight: 400;\">The function <\/span><span style=\"font-weight: 400;\">LCD_Write_Cmd<\/span><span style=\"font-weight: 400;\"> that takes an unsigned 8-bit integer (<\/span><span style=\"font-weight: 400;\">uint8_t<\/span><span style=\"font-weight: 400;\">) as an argument named <\/span><span style=\"font-weight: 400;\">cmd<\/span><span style=\"font-weight: 400;\">. The purpose of the function is to write a command to an LCD display using SPI (Serial Peripheral Interface) communication.<\/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=\"color: #000000;\"><span style=\"color: #008000;\"><b>SPI_TypeDef *pSPI = SPI;<\/b><\/span><span style=\"font-weight: 400;\"> &#8211; This line creates a pointer variable <\/span><span style=\"font-weight: 400;\">pSPI<\/span><span style=\"font-weight: 400;\"> of type <\/span><span style=\"font-weight: 400;\">SPI_TypeDef<\/span><span style=\"font-weight: 400;\"> and initializes it to the memory address of the SPI module (presumably defined elsewhere in the codebase).<\/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=\"color: #000000;\"><span style=\"color: #008000;\"><b>LCD_CSX_LOW();<\/b><\/span><span style=\"font-weight: 400;\"> &#8211; This line appears to be calling a function to set the chip select (CSX) pin of the LCD display to a low logic level, indicating that the display is active.<\/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=\"color: #000000;\"><span style=\"color: #008000;\"><b>LCD_DCX_LOW();<\/b><\/span><span style=\"font-weight: 400;\"> &#8211; This line also appears to be calling a function to set the data\/command (DCX) pin of the LCD display to a low logic level, indicating that the subsequent data being sent over the SPI protocol will be a command (as opposed to data).<\/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=\"color: #000000;\"><span style=\"color: #008000;\"><b>while(!REG_READ_BIT(pSPI-&gt;SR, SPI_SR_TXE_Pos));<\/b><\/span><span style=\"font-weight: 400;\"> &#8211; This line waits in a loop until the transmit buffer of the SPI module is empty (i.e., the TXE bit of the SPI status register is set to 1).<\/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=\"color: #000000;\"><span style=\"color: #008000;\"><b>REG_WRITE(pSPI-&gt;DR, cmd);<\/b><\/span><span style=\"font-weight: 400;\"> &#8211; This line writes the command value <\/span><span style=\"font-weight: 400;\">cmd<\/span><span style=\"font-weight: 400;\"> to the SPI data register (DR) of the SPI module.<\/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=\"color: #000000;\"><span style=\"color: #008000;\"><b>while(REG_READ_BIT(pSPI-&gt;SR, SPI_SR_BSY_Pos));<\/b><\/span><span style=\"font-weight: 400;\"> &#8211; This line waits in a loop until the SPI module is no longer busy (i.e., the BSY bit of the SPI status register is set to 0), indicating that the command has been successfully transmitted.<\/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=\"color: #000000;\"><span style=\"color: #008000;\"><b>LCD_DCX_HIGH();<\/b><\/span><span style=\"font-weight: 400;\"> &#8211; This line sets the data\/command (DCX) pin of the LCD display to a high logic level, indicating that subsequent data being sent over the SPI protocol will be actual display data (as opposed to a command).<\/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=\"color: #000000;\"><span style=\"color: #008000;\"><b>LCD_CSX_HIGH();<\/b><\/span><span style=\"font-weight: 400;\"> &#8211; This line sets the chip select (CSX) pin of the LCD display to a high logic level, indicating that the display is no longer active.<\/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;\">In summary, this code defines a function for writing a command to an LCD display using SPI protocol, by setting up the SPI module, sending the command over SPI, and controlling the relevant pins of the LCD display.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<h3 style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 20px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"text-decoration: underline; color: #000080;\"><b>LCD Write Data<\/b><\/span><\/h3>\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 code you provided is a function called <\/span><span style=\"font-weight: 400;\">LCD_Write_Data()<\/span><span style=\"font-weight: 400;\"> which writes data to an LCD display using SPI communication protocol. Here is a breakdown of what the code is doing:<\/span><\/span><\/p>\n<ol 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=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">The function takes two arguments: a pointer to a buffer of data (<\/span><span style=\"font-weight: 400;\">uint8_t *buffer<\/span><span style=\"font-weight: 400;\">) and the length of the buffer (<\/span><span style=\"font-weight: 400;\">uint32_t len<\/span><span style=\"font-weight: 400;\">).<\/span><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">It initializes a pointer to the SPI peripheral (<\/span><span style=\"font-weight: 400;\">SPI_TypeDef *pSPI = SPI;<\/span><span style=\"font-weight: 400;\">). This pointer is used to access the SPI control and data registers.<\/span><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">The function enters a while loop that iterates <\/span><span style=\"font-weight: 400;\">len<\/span><span style=\"font-weight: 400;\"> number of times, where <\/span><span style=\"font-weight: 400;\">len<\/span><span style=\"font-weight: 400;\"> is the length of the buffer.<\/span><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Inside the while loop, the function sets the chip select (CS) line for the LCD to LOW (<\/span><span style=\"font-weight: 400;\">LCD_CSX_LOW()<\/span><span style=\"font-weight: 400;\">). This indicates to the LCD that data is about to be sent.<\/span><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">The function then enters another while loop that waits for the Transmit Buffer Empty (TXE) flag in the SPI status register (SR) to be set (<\/span><span style=\"font-weight: 400;\">while(!REG_READ_BIT(pSPI-&gt;SR,SPI_SR_TXE_Pos))<\/span><span style=\"font-weight: 400;\">). This ensures that the SPI interface is ready to accept new data.<\/span><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">The function writes the data from the buffer to the SPI data register (DR) using a register write function (<\/span><span style=\"font-weight: 400;\">REG_WRITE(pSPI-&gt;DR, buffer[i]);<\/span><span style=\"font-weight: 400;\">). This sends the data to the LCD.<\/span><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">The function then enters another while loop that waits for the Busy (BSY) flag in the SPI status register (SR) to be cleared (<\/span><span style=\"font-weight: 400;\">while(REG_READ_BIT(pSPI-&gt;SR, SPI_SR_BSY_Pos))<\/span><span style=\"font-weight: 400;\">). This ensures that the SPI interface has finished sending the data.<\/span><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Finally, the function sets the CS line for the LCD to HIGH (<\/span><span style=\"font-weight: 400;\">LCD_CSX_HIGH()<\/span><span style=\"font-weight: 400;\">). This indicates to the LCD that the data transmission is complete.<\/span><\/span><\/li>\n<\/ol>\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;\">In summary, the <\/span><span style=\"font-weight: 400;\">LCD_Write_Data()<\/span><span style=\"font-weight: 400;\"> function sends a buffer of data to an LCD display over the SPI interface. It does so by setting the CS line low, waiting for the SPI interface to be ready, writing the data to the SPI data register, waiting for the SPI interface to finish sending the data, and setting the CS line high to indicate the end of the transmission.<\/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;\">And also define similar macros for RESX, CSX, and DCX, as shown in Figure 7.<\/span><\/p>\n<figure id=\"attachment_14734\" aria-describedby=\"caption-attachment-14734\" style=\"width: 740px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14734 \" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/05\/Figure-7-4.png\" alt=\"Figure 7. Macros\" width=\"740\" height=\"472\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-7-4.png 1093w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-7-4-300x191.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-7-4-1024x653.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-7-4-768x490.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-7-4-600x383.png 600w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><figcaption id=\"caption-attachment-14734\" class=\"wp-caption-text\">Figure 7. Macros<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_14735\" aria-describedby=\"caption-attachment-14735\" style=\"width: 699px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14735 \" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/05\/Figure-8-2.png\" alt=\"Figure 8. LCD_Reset code\" width=\"699\" height=\"378\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-8-2.png 1016w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-8-2-300x162.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-8-2-768x415.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-8-2-600x324.png 600w\" sizes=\"(max-width: 699px) 100vw, 699px\" \/><figcaption id=\"caption-attachment-14735\" class=\"wp-caption-text\">Figure 8. LCD_Reset code<\/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;\">A function LCD_Reset, which is used to reset an LCD display.&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;\">The function performs the following steps:<\/span><\/p>\n<ol 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=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Pulls the reset pin low<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Waits for 50ms (using a for loop)<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Pulls the reset pin high<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Waits for another 50ms (using a for loop)<\/span><\/li>\n<\/ol>\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 use the macros, you need to import the header file for lLI9341, which I have attached to the Inc folder. The file is called &#8220;ili9341_reg&#8221; and contains all the necessary command definitions.<\/span><\/p>\n<figure id=\"attachment_14736\" aria-describedby=\"caption-attachment-14736\" style=\"width: 834px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14736 \" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/05\/Figure-9-2.png\" alt=\"Figure 9. Commands\" width=\"834\" height=\"345\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-9-2.png 1675w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-9-2-300x124.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-9-2-1024x424.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-9-2-768x318.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-9-2-600x248.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-9-2-1536x635.png 1536w\" sizes=\"(max-width: 834px) 100vw, 834px\" \/><figcaption id=\"caption-attachment-14736\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 9. Commands<\/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;\">You have to include that command here in bsp_lcd.c, as shown in Figure 10.<\/span><\/p>\n<figure id=\"attachment_14737\" aria-describedby=\"caption-attachment-14737\" style=\"width: 731px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14737 \" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/05\/Figure-10-2.png\" alt=\"Figure 10. Header file\" width=\"731\" height=\"349\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-10-2.png 1188w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-10-2-300x143.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-10-2-1024x489.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-10-2-768x367.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-10-2-600x286.png 600w\" sizes=\"(max-width: 731px) 100vw, 731px\" \/><figcaption id=\"caption-attachment-14737\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 10. Header 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; color: #000000;\">When you call the BSP_LCD_Init function from the main program, the Pin will be initialized, and the SPI peripheral will also be initialized. A Reset pulse will be sent to the display module, and LCD_config will send a few commands.<\/span><\/p>\n<figure id=\"attachment_14738\" aria-describedby=\"caption-attachment-14738\" style=\"width: 639px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14738 \" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/05\/Figure-11.png\" alt=\"Figure 11. BSP_LCD_Init\" width=\"639\" height=\"250\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-11.png 917w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-11-300x117.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-11-768x301.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-11-600x235.png 600w\" sizes=\"(max-width: 639px) 100vw, 639px\" \/><figcaption id=\"caption-attachment-14738\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 11. BSP_LCD_Init<\/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;\">We will use the logic analyzer in the following article.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 20px; font-family: 'Roboto Slab'; font-weight: 400; 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; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\">Click here:<\/span>&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=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&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; ILI9341 TFT-LCD Initialization commands &nbsp; In this article, let\u2019s understand the significance of the RESX, CSX, and DCX pins. You can find RESX, CSX, D\/CX signals in the datasheet of the ILI9341 chip.&nbsp; You can see Figure 1, these 3 signals are inputs to the chip. &nbsp; All the pin descriptions you can see [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":14728,"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":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","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":"default","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-14725","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>ILI9341 TFT-LCD Initialization commands<\/title>\n<meta name=\"description\" content=\"ILI9341 TFT-LCD Initialization commands. Understand the significance of the RESX, CSX, and DCX pins. RESX: This signal will reset the device\" \/>\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-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ILI9341 TFT-LCD Initialization commands\" \/>\n<meta property=\"og:description\" content=\"ILI9341 TFT-LCD Initialization commands. Understand the significance of the RESX, CSX, and DCX pins. RESX: This signal will reset the device\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\/\" \/>\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-20T04:10:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-30T11:14:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-1-6.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1835\" \/>\n\t<meta property=\"og:image:height\" content=\"881\" \/>\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=\"9 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-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"STM32-LTDC, LCD-TFT, LVGL(MCU3) Lecture 30| ILI9341 TFT-LCD Initialization commands\",\"datePublished\":\"2023-05-20T04:10:49+00:00\",\"dateModified\":\"2023-06-30T11:14:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\\\/\"},\"wordCount\":1643,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/Figure-1-6.png\",\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\\\/\",\"name\":\"ILI9341 TFT-LCD Initialization commands\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/Figure-1-6.png\",\"datePublished\":\"2023-05-20T04:10:49+00:00\",\"dateModified\":\"2023-06-30T11:14:46+00:00\",\"description\":\"ILI9341 TFT-LCD Initialization commands. Understand the significance of the RESX, CSX, and DCX pins. RESX: This signal will reset the device\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/Figure-1-6.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/Figure-1-6.png\",\"width\":1835,\"height\":881,\"caption\":\"Figure 1. RESX, CSX,D\\\/CX pins\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\\\/#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 30| ILI9341 TFT-LCD Initialization commands\"}]},{\"@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":"ILI9341 TFT-LCD Initialization commands","description":"ILI9341 TFT-LCD Initialization commands. Understand the significance of the RESX, CSX, and DCX pins. RESX: This signal will reset the device","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-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\/","og_locale":"en_US","og_type":"article","og_title":"ILI9341 TFT-LCD Initialization commands","og_description":"ILI9341 TFT-LCD Initialization commands. Understand the significance of the RESX, CSX, and DCX pins. RESX: This signal will reset the device","og_url":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2023-05-20T04:10:49+00:00","article_modified_time":"2023-06-30T11:14:46+00:00","og_image":[{"width":1835,"height":881,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-1-6.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":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"STM32-LTDC, LCD-TFT, LVGL(MCU3) Lecture 30| ILI9341 TFT-LCD Initialization commands","datePublished":"2023-05-20T04:10:49+00:00","dateModified":"2023-06-30T11:14:46+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\/"},"wordCount":1643,"commentCount":0,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-1-6.png","articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\/","url":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\/","name":"ILI9341 TFT-LCD Initialization commands","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-1-6.png","datePublished":"2023-05-20T04:10:49+00:00","dateModified":"2023-06-30T11:14:46+00:00","description":"ILI9341 TFT-LCD Initialization commands. Understand the significance of the RESX, CSX, and DCX pins. RESX: This signal will reset the device","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-1-6.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/05\/Figure-1-6.png","width":1835,"height":881,"caption":"Figure 1. RESX, CSX,D\/CX pins"},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/stm32-ltdc-lcd-tft-lvglmcu3-lecture-30-ili9341-tft-lcd-initialization-commands\/#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 30| ILI9341 TFT-LCD Initialization commands"}]},{"@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\/14725","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=14725"}],"version-history":[{"count":5,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/14725\/revisions"}],"predecessor-version":[{"id":14962,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/14725\/revisions\/14962"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/14728"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=14725"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=14725"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=14725"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}