查看: 313|回复: 0

[分享] 【MCX-N947分享】+Flexio驱动8080 TFT_LCD

[复制链接]
  • TA的每日心情
    开心
    昨天 17:11
  • 签到天数: 821 天

    [LV.10]以坛为家III

    71

    主题

    2447

    帖子

    24

    金牌会员

    Rank: 6Rank: 6

    积分
    5522
    最后登录
    2024-4-27
    发表于 2024-3-10 15:27:52 | 显示全部楼层 |阅读模式
    本帖最后由 leo121_3006061 于 2024-4-4 19:57 编辑

            今天主要学习flexio来驱动16bit mpu8080 接口的TFT_LCD并记录下来和大家分享我的学习过程,flexio可以实现很多功能,例如pwm,can,spi,模拟camera,可见功能强大,开始本次实验之前,首先回顾以下mcxn947芯片的诸多令人兴奋的新特性。
    FeaturesCore Platform
    • Arm® Cortex®-M33 @ 150 MHz (Dual core)
    • DSP Accelerator (PowerQUAD, with Co-Processor interface)
    • SmartDMA (co-processor for applications such as parallel camera interface and keypad scanning)
    • eIQ® Neutron N1-16 Neural Processing Unit
    • Power Line Communications (PLC) Controller

    Memory
    • Up to 2 MB (2 x 1MB Bank) on chip Flash
      • Supporting Flash Swap and Read While Write
    • Cache Engine with 16 KB RAM
    • Up to 512 KB RAM, configurable as up to 416 KB with ECC (support single bit correction two bits detection)
      • Up to 4x 8 KB ECC RAM can be retained down to VBAT mode
    • FlexSPI with 16 KB cache supporting XIP, Octal/Quad SPI flash, HyperFlash, HyperRAM, Xccela memory types

    Peripher
    als
    • Analog
      • 4x 16bit ADC (Single Ended) or 2x16bit (Differential)
        • Up to 2 Msps in 16bit mode and 3.3 Msps in 12bit mode
      • Integrated temperature sensor connected per ADC
      • Three high-speed comparators with 17 input pins and 8-bit DAC as internal reference
        • 2x CMP is functional down to Deep Power Down mode
      • Two 12-bit DAC with sample rates of up to 1.0 MSample/sec
      • One 14-bit DAC with sample rates of up to 10 MSample/sec
      • Three OpAmps can be configured to:
        • Programmable Gain Amplifier
        • Differential Amplifier
        • Instrument Amplifier
        • Transconductance Amplifier
      • Highly accurate VREF ±0.15 % and 15 ppm/deg C drift
    • Timers
      • Five 32-bit standard general-purpose asynchronous timers/counters, which support up to four capture inputs and four compare outputs, PWM mode and external count input. Specific timer events can be selected to generate DMA requests.
      • SCTimer/PWM
      • LPTimer
      • Frequency measurement timer
      • Multi-Rate Timer
      • Windowed Watchdog Timer
      • RTC with calendar
      • Micro Timer
      • OS Event Timer
    • Communication interfaces
      • USB high-speed (Host/Device) with on-chip HS PHY
      • USB full-speed (Host/Device) with on-chip FS PHY, USB Device
      • uSDHC (Micro SD High Speed Card Interface)
      • 10x LP Flexcomms each supporting SPI, I2C, UART
      • 2x FlexCAN with FD, 2x I3Cs, 2x SAI
      • 1x Ethernet with QoS
      • 1x FlexIO programmable as a variety of serial and parallel interfaces, including, but not limited to Display Driver and camera interface
      • 2x EVM Smart Card Interfaces
      • Programmable Logic Unit (PLU)
    • Motor Control Subsystem
      • 2x eFlexPWM each with 4 sub-modules, providing 12 PWM outputs
      • 2x Quadrature Encoder/Decoder (ENC)
      • 1x Event Generator (AND/OR/INVERT) module support up to 8 output trigger
      • SINC Filter Module (3rd order, 5ch, break signals connections to PWM)

    Security


    再看一下架构图,图形是工程师语言,上边的千言万语汇集成一张图
    Screenshot from 2024-03-03 13-59-55.png
    开始今天的实验过程
    【软件:】
    OS:windows11
    Dev tools:MDK Keil
    sdk: mcuxpresso sdk 2.14
    【硬件:】
    mcxn947_brk开发板
    HX8357A tft_lcd
    杜邦线
    dap link
    【设置】

    从原理图中可以看出点屏所需要的pin设置
    Screenshot from 2024-03-03 14-19-12.png
    由于屏的转接板不能和这个开发板很好的契合,所以二者之间需要用大量的杜邦线来连接。

    【实验过程】
    1. 为了快速开发,直接使用官方的例程,从sdk中打开lvgl_demo_widgets,
    Screenshot 2024-03-10 072452.png 也可用drivers_example/flexio/mculcd来修改
    Screenshot 2024-03-10 072553.png
    先了解一下flexio驱动lcd的过程,1.先设置好flexio,并配置好pin =》 2. 初始化flexio及pin=》 3.设置lcd的属性=》4.初始化lcd。
    由于我用的lcd是HX8357A,翻阅手册发现和例程里使用的ST7796s的寄存器完全不同,需要重新构造初始化,开窗函数等,过程费时
    2.直接用st7796s修改初lcd始化参数。
    Screenshot 2024-03-10 065029.png

    附上初始化代码,如下
    1. 0x01, 0xFF,0x00,  // Command page 0
    2.         0x01, 0x72,0xF6,  // SUB_SEL=0xF6
    3.         // Power saving for HX8357-A
    4.         0x01, 0xFF,0x00,  // Command page 0
    5.         0x01, 0xF2,0x00,  // GENON=0x00
    6.         0x01, 0xE4,0x00,  // EQVCI_M1=0x00
    7.         0x01, 0xE5,0x1C,  // EQGND_M1=0x1C
    8.         0x01, 0xE6,0x00,  // EQVCI_M0=0x1C
    9.         0x01, 0xE7,0x1C,  // EQGND_M0=0x1C
    10.         0x01, 0xEE,0x42,  // For GRAM read/write speed
    11.         0x01, 0xEF,0xDB,  // For GRAM read/write speed
    12.          0x01, 0x2E,0x98,  //For Gate timing, prevent the display abnormal in RGB I/F
    13.         // Gamma
    14.         0x01, 0x40,0x00,  
    15.         0x01, 0x41,0x2E,  
    16.         0x01, 0x42,0x2D,  
    17.         0x01, 0x43,0x3F,  
    18.         0x01, 0x44,0x3F,  
    19.         0x01, 0x45,0x3F,  
    20.         0x01, 0x46,0x2C,  
    21.         0x01, 0x47,0x7F,  
    22.         0x01, 0x48,0x07,  
    23.         0x01, 0x49,0x05,  
    24.         0x01, 0x4A,0x08,  
    25.         0x01, 0x4B,0x13,  
    26.         0x01, 0x4C,0x1E,  
    27.         0x01, 0x50,0x00,  
    28.         0x01, 0x51,0x00,  
    29.         0x01, 0x52,0x00,  
    30.         0x01, 0x53,0x12,  
    31.         0x01, 0x54,0x11,  
    32.         0x01, 0x55,0x3F,  
    33.         0x01, 0x56,0x00,  
    34.         0x01, 0x57,0x53,  
    35.         0x01, 0x58,0x01,  
    36.         0x01, 0x59,0x0C,  
    37.         0x01, 0x5A,0x17,  
    38.         0x01, 0x5B,0x1A,  
    39.         0x01, 0x5C,0x18,  
    40.         0x01, 0x5D,0xC3,  
    41.         
    42.         
    43.         
    44.         // Set GRAM area 320x480
    45.         0x01, 0x02,0x00,  
    46.         0x01, 0x03,0x00,  
    47.         0x01, 0x04,0x01,  
    48.         0x01, 0x05,0x3F,  
    49.         0x01, 0x06,0x00,  
    50.         0x01, 0x07,0x00,  
    51.         0x01, 0x08,0x00,  
    52.         0x01, 0x09,0xDF, //0xEF 320x240
    53.          
    54.         0x01, 0x24,0x22,  // Set VCOMH voltage, VHH=0x64
    55.         0x01, 0x25,0x64,  // Set VCOML voltage, VML=0x71
    56.         0x01, 0x23,0x90,  // Set VCOM offset, VMF=0x52
    57.         0x01, 0x1B,0x0E,  // Set VERG1 voltage, VRH[5:0]=0x1E
    58.         0x01, 0x1D,0x11,  // FS0[1:0]=01, Set the operating frequency of the step-up circuit 1
    59.         // Power on Setting
    60.         0x01, 0x19,0x01,  // OSC_EN=1, Start to Oscillate
    61.         0x01, 0x1C,0x03,  // AP=011
    62.         0x01, 0x01,0x00,  // Normal display(Exit Deep standby mode)
    63.         0x01, 0x1F,0x80,  // Exit standby mode and Step-up circuit 1 enable
    64.         // GAS_EN=1, VCOMG=0, PON=0, DK=0, XDK=0, DDVDH_TRI=0, STB=0
    65.          
    66.         0x01, 0x1F,0x90,  // Step-up circuit 2 enable
    67.         // GAS_EN=1, VCOMG=0, PON=1, DK=0, XDK=0, DDVDH_TRI=0, STB=0
    68.          
    69.         0x01, 0x1F,0xD4,  
    70.         // GAS_EN=1, VCOMG=1, PON=1, DK=0, XDK=1, DDVDH_TRI=0, STB=0
    71.          
    72.         // Display ON Setting
    73.         0x01, 0x28,0x08,  // GON=0, DTE=0, D[1:0]=01
    74.          
    75.         0x01, 0x28,0x38,  // GON=1, DTE=1, D[1:0]=10
    76.          
    77.         0x01, 0x28,0x3C,  // GON=1, DTE=1, D[1:0]=11
    78.          

    79.          0x01, 0x17,0x05,  // 16-bit/pixel         
    80.          
    81.          //HX8357-A_Update_GRAM
    82.          // Set GRAM start address (0x0000, 0x0000)
    83.          0x01,0xFF,0x00, ////Select Command Page 0
    84.          // If command page not change, the RFFh can remove
    85.          0x01,0x80,0x00, // Set CAC=0x0000
    86.    0x01,0x81,0x00,
    87.          0x01,0x82,0x00, // Set RAC=0x0000
    88.    0x01,0x83,0x00,
    89.    0x00,0x22, //Write GRAM command
    90.          
    复制代码
    修改开窗函数
    Screenshot 2024-03-10 065453.png
    经过这一阵子的研究,重新画板子,终于成功了,补发几张图完善本贴。 62060A3A@2753A42F.2D930E6600000000.jpg
    CB009596@71713D6E.2D930E6600000000.jpg
    532C35D9@DB2E812A.2D930E6600000000.jpg



    表示已经成功了。
    lvgl_demo_widgets.zip (116.64 KB, 下载次数: 1)
    该会员没有填写今日想说内容.
    回复

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /4 下一条

    Archiver|手机版|小黑屋|恩智浦技术社区

    GMT+8, 2024-4-28 00:02 , Processed in 0.136110 second(s), 20 queries , MemCache On.

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.

    快速回复 返回顶部 返回列表