STM32f4---TFTLCD display experimental code (06)

Publisher:EnchantedBreezeLatest update time:2018-09-29 Source: eefocusKeywords:STM32f4 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Special note: This function uses printf to print the LCD ID, so if you do not initialize the serial port in the main function, the program will die in printf! ! If you do not want to use printf, please comment it out.

This is the end of the LCD driver related functions. Next, let's look at the main function code as follows:

int main(void)

{  

    x=0;

  u8 lcd_id[12]; //Store LCD ID string

  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //Set system interrupt priority group 2

  delay_init(168); //Initialize delay function

  uart_init(115200); //Initialize the serial port baud rate to 115200

  

  LED_Init(); //Initialize LED

    LCD_Init(); //Initialize LCD FSMC interface

  POINT_COLOR=RED;  

  sprintf((char*)lcd_id,"LCD ID:X",lcddev.id);//Print LCD ID to lcd_id array.

     while(1)  

  {      

    switch(x)

    {

      case 0:LCD_Clear(WHITE);break;

      case 1:LCD_Clear(BLACK);break;

      case 2:LCD_Clear(BLUE);break;

      case 3:LCD_Clear(RED);break;

      case 4:LCD_Clear(MAGENTA);break;

      case 5:LCD_Clear(GREEN);break;

      case 6:LCD_Clear(CYAN);break;  

      case 7:LCD_Clear(YELLOW);break;

      case 8:LCD_Clear(BRRED);break;

      case 9:LCD_Clear(GRAY);break;

      case 10:LCD_Clear(LGRAY);break;

      case 11:LCD_Clear(BROWN);break;

    }

    POINT_COLOR=RED;     

    LCD_ShowString(30,40,210,24,24,"Explorer STM32F4");  

    LCD_ShowString(30,70,200,16,16,"TFTLCD TEST");

    LCD_ShowString(30,90,200,16,16,"ATOM@ALIENTEK");

      LCD_ShowString(30,110,200,16,16,lcd_id); //Show LCD ID           

        

    LCD_ShowString(30,130,200,12,12,"2014/5/4");                    

       x++;

    if(x==12)x=0;

    LED0=!LED0;delay_ms(1000);  

  }  

}

This part of the code will display some fixed characters, with font sizes of 24*12, 16*8 and 12*6, and the model of the LCD driver IC, and then switch the background color continuously, switching once every 1s. LED0 will also flash continuously, indicating that the program is running. We use a sprintf function, which is used in the same way as printf, except that sprintf outputs the printed content to the specified memory range. For detailed usage of sprintf, please search Baidu.

Also pay special attention: the uart_init function cannot be removed, because printf is called in the LCD_Init function, so once you remove this initialization, the system will freeze! In fact, as long as your code uses printf, you must initialize the serial port, otherwise it will freeze, that is, stop at the fputc function in usart.c and cannot get out.


Keywords:STM32f4 Reference address:STM32f4---TFTLCD display experimental code (06)

Previous article:STM32f4 key input experimental code (01)
Next article:STM32f4---TFTLCD display experimental code (05)

Recommended ReadingLatest update time:2024-11-16 14:33

STM32f4---Marquee Experiment Code
Enter the following code in the led.c file #include "led.h"   //Initialize PF9 and PF10 as output ports and enable the clocks of these two ports          //LED IO initialization void LED_Init(void) {             GPIO_InitTypeDef  GPIO_InitStructure;    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, ENABLE); //Enable GPI
[Microcontroller]
Use the STM32F4XX built-in math library "arm_math.h"
STM32-F4 belongs to the Cortex-M4F architecture. The biggest difference between it and M0 and M3 is that it has FPU (floating-point unit) and supports floating-point instruction set. Therefore, it can perform dozens or even hundreds of times better than M0/M3 when processing mathematical operations. However, to give fu
[Microcontroller]
Stm32f407DISCOVEY study uart serial port baud rate summary
I have been debugging Stm32f407DISCOVEY these days. Since there is no ready-made library function routine for the serial port, I used the routine on the Shenzhouwang development board to directly debug. As a result, the serial port output is always messy, 115200 baud rate; I tried to change it to 38400 and it can actu
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号