打印
[AT32F403/403A]

AT32F403AVGT7 XMC驱动16bit HX8369A TFT的问题

[复制链接]
946|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
admvip|  楼主 | 2023-6-27 20:24 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
使用AT32F403AVGT7来驱动HX8369A 16bit并口TFT,初始化后没能点亮,帮忙大佬们看下初始化代码是否正确。XMC的的初始化代码借鉴了库例程,不过没有使用例程的XMC引脚映射,使用了默认的XMC引脚配置,感觉端口占用比较连续。
PD14        XMC_D0
PD15        XMC_D1

PD0        XMC_D2
PD1        XMC_D3

PE7        XMC_D4
PE8        XMC_D5
PE9        XMC_D6
PE10        XMC_D7
PE11        XMC_D8
PE12        XMC_D9
PE13        XMC_D10
PE14        XMC_D11
PE15        XMC_D12

PD8        XMC_D13
PD9        XMC_D14
PD10        XMC_D15

PD3        LCD_RESET
PD4        XMC_NOE       RD
PD5        XMC_NWE      WR


PD7        XMC_NE1       液晶屏片选引脚

PD11        XMC_A16       RS


/**
  * @brief  LCD界面IO及XMC初始化
  *         this function must be called before any write/read operation
  *         on the lcd.
  * @param  none
  * @retval none
  */
void xmc_init(void)
{
  gpio_init_type  gpio_init_struct = {0};
  xmc_norsram_init_type  xmc_norsram_init_struct;
  xmc_norsram_timing_init_type rw_timing_struct, w_timing_struct;

  /* enable the gpio clock */
  crm_periph_clock_enable(CRM_GPIOD_PERIPH_CLOCK, TRUE);
  crm_periph_clock_enable(CRM_GPIOE_PERIPH_CLOCK, TRUE);

  /* enable the xmc clock */
  crm_periph_clock_enable(CRM_XMC_PERIPH_CLOCK, TRUE);

  /* remap 使用默认remap,注释掉下面两行*/
  //crm_periph_clock_enable(CRM_IOMUX_PERIPH_CLOCK, TRUE);
  //gpio_pin_remap_config(XMC_GMUX_001, TRUE);

  /*-- gpio configuration ------------------------------------------------------*/
  /* lcd data lines configuration */
  gpio_init_struct.gpio_pins = GPIO_PINS_0 | GPIO_PINS_1 | GPIO_PINS_8 | GPIO_PINS_9 | GPIO_PINS_10 | GPIO_PINS_14 | GPIO_PINS_15;
  gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
  gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
  gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
  gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
  gpio_init(GPIOD, &gpio_init_struct);

  gpio_init_struct.gpio_pins = GPIO_PINS_7 | GPIO_PINS_8 | GPIO_PINS_9 | GPIO_PINS_10 | GPIO_PINS_11 | GPIO_PINS_12 | GPIO_PINS_13 | GPIO_PINS_14 | GPIO_PINS_15;
  gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
  gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
  gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
  gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
  gpio_init(GPIOE, &gpio_init_struct);


  /* lcd reset(pd3) lines configuration */
  gpio_init_struct.gpio_pins = GPIO_PINS_3;
  gpio_init_struct.gpio_mode = GPIO_MODE_OUTPUT;
  gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
  gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
  gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
  gpio_init(GPIOD, &gpio_init_struct);

  /* lcd rs(pd11)/cs(pd7)/wr(pd5)/rd(pd4) lines configuration */
  gpio_init_struct.gpio_pins = GPIO_PINS_4 | GPIO_PINS_5 | GPIO_PINS_7 | GPIO_PINS_11;
  gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
  gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
  gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
  gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
  gpio_init(GPIOD, &gpio_init_struct);

  /*-- xmc configuration ------------------------------------------------------*/
  xmc_norsram_default_para_init(&xmc_norsram_init_struct);
  xmc_norsram_init_struct.subbank = XMC_BANK1_NOR_SRAM1;
  xmc_norsram_init_struct.data_addr_multiplex = XMC_DATA_ADDR_MUX_DISABLE;
  xmc_norsram_init_struct.device = XMC_DEVICE_SRAM;
  xmc_norsram_init_struct.bus_type = XMC_BUSTYPE_16_BITS;
  xmc_norsram_init_struct.burst_mode_enable = XMC_BURST_MODE_DISABLE;
  xmc_norsram_init_struct.asynwait_enable = XMC_ASYN_WAIT_DISABLE;
  xmc_norsram_init_struct.wait_signal_lv = XMC_WAIT_SIGNAL_LEVEL_LOW;
  xmc_norsram_init_struct.wrapped_mode_enable = XMC_WRAPPED_MODE_DISABLE;
  xmc_norsram_init_struct.wait_signal_config = XMC_WAIT_SIGNAL_SYN_BEFORE;
  xmc_norsram_init_struct.write_enable = XMC_WRITE_OPERATION_ENABLE;
  xmc_norsram_init_struct.wait_signal_enable = XMC_WAIT_SIGNAL_DISABLE;
  xmc_norsram_init_struct.write_timing_enable = XMC_WRITE_TIMING_ENABLE;
  xmc_norsram_init_struct.write_burst_syn = XMC_WRITE_BURST_SYN_DISABLE;
  xmc_nor_sram_init(&xmc_norsram_init_struct);

  /* timing configuration */
  xmc_norsram_timing_default_para_init(&rw_timing_struct, &w_timing_struct);
  rw_timing_struct.subbank = XMC_BANK1_NOR_SRAM1;
  rw_timing_struct.write_timing_enable = XMC_WRITE_TIMING_ENABLE;
  rw_timing_struct.addr_setup_time = 0x2;
  rw_timing_struct.addr_hold_time = 0x0;
  rw_timing_struct.data_setup_time = 0x2;
  rw_timing_struct.bus_latency_time = 0x0;
  rw_timing_struct.clk_psc = 0x0;
  rw_timing_struct.data_latency_time = 0x0;
  rw_timing_struct.mode = XMC_ACCESS_MODE_A;
  w_timing_struct.subbank = XMC_BANK1_NOR_SRAM1;
  w_timing_struct.write_timing_enable = XMC_WRITE_TIMING_ENABLE;
  w_timing_struct.addr_setup_time = 0x2;
  w_timing_struct.addr_hold_time = 0x0;
  w_timing_struct.data_setup_time = 0x2;
  w_timing_struct.bus_latency_time = 0x0;
  w_timing_struct.clk_psc = 0x0;
  w_timing_struct.data_latency_time = 0x0;
  w_timing_struct.mode = XMC_ACCESS_MODE_A;
  xmc_nor_sram_timing_config(&rw_timing_struct, &w_timing_struct);

  /* bus turnaround phase for consecutive read duration and consecutive write duration */
  xmc_ext_timing_config(XMC_BANK1_NOR_SRAM1, 0x08, 0x08);

  /* enable xmc_bank1_nor_sram4 */
  xmc_nor_sram_enable(XMC_BANK1_NOR_SRAM1, TRUE);
}


/**
  * @brief  LCD 软件初始化
  *         this function must be called before any write/read operation
  *         on the lcd.
  * @param  none
  * @retval none
  */
void lcd_init(void)
{
  /* init xmc */
  lcd_struct->xmc_init();

  /* Hardware RESET */
  LCD_RESET_HIGH();
  delay_ms(100);
  LCD_RESET_LOW();
  delay_ms(150);
  LCD_RESET_HIGH();
  delay_ms(150);

  /* Softwave RESET */
//  lcd_wr_command(0x01);
//  delay_ms(150);

  /* read id */
//  lcd_wr_command(0x0000);
//  delay_ms(5);

//  lcd_struct->lcd_id = lcd_rd_data();
//  lcd_wr_command(0xD3);

//  lcd_struct->lcd_id = lcd_rd_data();
//  lcd_struct->lcd_id = lcd_rd_data();
//  lcd_struct->lcd_id = lcd_rd_data();
//  lcd_struct->lcd_id = lcd_rd_data();
//  lcd_struct->lcd_id = lcd_struct->lcd_id << 8;
//  lcd_struct->lcd_id |= lcd_rd_data();

  /* HX8369A Init Code */
  lcd_wr_command(0xB9);       //HX8369A_SETEXTC
  lcd_wr_data(0xFF);
  lcd_wr_data(0x83);
  lcd_wr_data(0x69);

  lcd_wr_command(0xF4);       //GET CHIP ID and VERSION
  lcd_struct->lcd_id = lcd_rd_data();
  lcd_struct->lcd_id = lcd_struct->lcd_id << 8;
  lcd_struct->lcd_id |= ((lcd_rd_data() << 8) >> 8);

  lcd_wr_command(0xB1);       //HX8369A_SETPOWER
  lcd_wr_data(0x01);
  lcd_wr_data(0x00);
  lcd_wr_data(0x34);
  lcd_wr_data(0x07);
  lcd_wr_data(0x00);
  lcd_wr_data(0x01);
  lcd_wr_data(0x0F);
  lcd_wr_data(0x2A);
  lcd_wr_data(0x32);
  lcd_wr_data(0x3F);
  lcd_wr_data(0x3F);
  lcd_wr_data(0x07);
  lcd_wr_data(0x10);
  lcd_wr_data(0x01);
  lcd_wr_data(0xE6);
  lcd_wr_data(0xE6);
  lcd_wr_data(0xE6);
  lcd_wr_data(0xE6);
  lcd_wr_data(0xE6);

  lcd_wr_command(0xB2);       //HX8369A_SETDISP
  lcd_wr_data(0x00);
  lcd_wr_data(0x10);
  lcd_wr_data(0x03);
  lcd_wr_data(0x03);
  lcd_wr_data(0x70);
  lcd_wr_data(0x00);
  lcd_wr_data(0xFF);
  lcd_wr_data(0x00);
  lcd_wr_data(0x00);
  lcd_wr_data(0x00);
  lcd_wr_data(0x00);
  lcd_wr_data(0x03);
  lcd_wr_data(0x03);
  lcd_wr_data(0x00);
  lcd_wr_data(0x01);

  lcd_wr_command(0xB4);       //HX8369A_SETCYC
  lcd_wr_data(0x00);
  lcd_wr_data(0x0C);
  lcd_wr_data(0xA0);
  lcd_wr_data(0x0E);
  lcd_wr_data(0x06);

  lcd_wr_command(0xB6);       //HX8369A_SETVCOM
  lcd_wr_data(0x2C);
  lcd_wr_data(0x2C);

  lcd_wr_command(0xD5);       //HX8369A_SETGIP
  lcd_wr_data(0x00);
  lcd_wr_data(0x05);
  lcd_wr_data(0x03);
  lcd_wr_data(0x00);
  lcd_wr_data(0x10);
  lcd_wr_data(0x09);
  lcd_wr_data(0x10);
  lcd_wr_data(0x80);
  lcd_wr_data(0x37);
  lcd_wr_data(0x37);
  lcd_wr_data(0x20);
  lcd_wr_data(0x31);
  lcd_wr_data(0x46);
  lcd_wr_data(0x8A);
  lcd_wr_data(0x57);
  lcd_wr_data(0x9B);
  lcd_wr_data(0x20);
  lcd_wr_data(0x31);
  lcd_wr_data(0x46);
  lcd_wr_data(0x8A);
  lcd_wr_data(0x57);
  lcd_wr_data(0x9B);
  lcd_wr_data(0x07);
  lcd_wr_data(0x0F);
  lcd_wr_data(0x02);
  lcd_wr_data(0x00);

  lcd_wr_command(0xE0);       //HX8369A_SETGAMMA
  lcd_wr_data(0x00);
  lcd_wr_data(0x08);
  lcd_wr_data(0x0D);
  lcd_wr_data(0x2D);
  lcd_wr_data(0x34);
  lcd_wr_data(0x3F);
  lcd_wr_data(0x19);
  lcd_wr_data(0x38);
  lcd_wr_data(0x09);
  lcd_wr_data(0x0E);
  lcd_wr_data(0x0E);
  lcd_wr_data(0x12);
  lcd_wr_data(0x14);
  lcd_wr_data(0x12);
  lcd_wr_data(0x14);
  lcd_wr_data(0x13);
  lcd_wr_data(0x19);
  lcd_wr_data(0x00);
  lcd_wr_data(0x08);
  lcd_wr_data(0x0D);
  lcd_wr_data(0x2D);
  lcd_wr_data(0x34);
  lcd_wr_data(0x3F);
  lcd_wr_data(0x19);
  lcd_wr_data(0x38);
  lcd_wr_data(0x09);
  lcd_wr_data(0x0E);
  lcd_wr_data(0x0E);
  lcd_wr_data(0x12);
  lcd_wr_data(0x14);
  lcd_wr_data(0x12);
  lcd_wr_data(0x14);
  lcd_wr_data(0x13);
  lcd_wr_data(0x19);

  lcd_wr_command(0xC1);       //HX8369A_SETDGCLUT
  lcd_wr_data(0x01);
  lcd_wr_data(0x02);          //
  lcd_wr_data(0x08);
  lcd_wr_data(0x12);
  lcd_wr_data(0x1A);
  lcd_wr_data(0x22);
  lcd_wr_data(0x2A);
  lcd_wr_data(0x31);
  lcd_wr_data(0x36);
  lcd_wr_data(0x3F);
  lcd_wr_data(0x48);
  lcd_wr_data(0x51);
  lcd_wr_data(0x58);
  lcd_wr_data(0x60);
  lcd_wr_data(0x68);
  lcd_wr_data(0x70);
  lcd_wr_data(0x78);
  lcd_wr_data(0x80);
  lcd_wr_data(0x88);
  lcd_wr_data(0x90);
  lcd_wr_data(0x98);
  lcd_wr_data(0xA0);
  lcd_wr_data(0xA7);
  lcd_wr_data(0xAF);
  lcd_wr_data(0xB6);
  lcd_wr_data(0xBE);
  lcd_wr_data(0xC7);
  lcd_wr_data(0xCE);
  lcd_wr_data(0xD6);
  lcd_wr_data(0xDE);
  lcd_wr_data(0xE6);
  lcd_wr_data(0xEF);
  lcd_wr_data(0xF5);
  lcd_wr_data(0xFB);
  lcd_wr_data(0xFC);
  lcd_wr_data(0xFE);
  lcd_wr_data(0x8C);
  lcd_wr_data(0xA4);
  lcd_wr_data(0x19);
  lcd_wr_data(0xEC);
  lcd_wr_data(0x1B);
  lcd_wr_data(0x4C);
  lcd_wr_data(0x40);
  lcd_wr_data(0x02);          //
  lcd_wr_data(0x08);
  lcd_wr_data(0x12);
  lcd_wr_data(0x1A);
  lcd_wr_data(0x22);
  lcd_wr_data(0x2A);
  lcd_wr_data(0x31);
  lcd_wr_data(0x36);
  lcd_wr_data(0x3F);
  lcd_wr_data(0x48);
  lcd_wr_data(0x51);
  lcd_wr_data(0x58);
  lcd_wr_data(0x60);
  lcd_wr_data(0x68);
  lcd_wr_data(0x70);
  lcd_wr_data(0x78);
  lcd_wr_data(0x80);
  lcd_wr_data(0x88);
  lcd_wr_data(0x90);
  lcd_wr_data(0x98);
  lcd_wr_data(0xA0);
  lcd_wr_data(0xA7);
  lcd_wr_data(0xAF);
  lcd_wr_data(0xB6);
  lcd_wr_data(0xBE);
  lcd_wr_data(0xC7);
  lcd_wr_data(0xCE);
  lcd_wr_data(0xD6);
  lcd_wr_data(0xDE);
  lcd_wr_data(0xE6);
  lcd_wr_data(0xEF);
  lcd_wr_data(0xF5);
  lcd_wr_data(0xFB);
  lcd_wr_data(0xFC);
  lcd_wr_data(0xFE);
  lcd_wr_data(0x8C);
  lcd_wr_data(0xA4);
  lcd_wr_data(0x19);
  lcd_wr_data(0xEC);
  lcd_wr_data(0x1B);
  lcd_wr_data(0x4C);
  lcd_wr_data(0x40);
  lcd_wr_data(0x02);          //
  lcd_wr_data(0x08);
  lcd_wr_data(0x12);
  lcd_wr_data(0x1A);
  lcd_wr_data(0x22);
  lcd_wr_data(0x2A);
  lcd_wr_data(0x31);
  lcd_wr_data(0x36);
  lcd_wr_data(0x3F);
  lcd_wr_data(0x48);
  lcd_wr_data(0x51);
  lcd_wr_data(0x58);
  lcd_wr_data(0x60);
  lcd_wr_data(0x68);
  lcd_wr_data(0x70);
  lcd_wr_data(0x78);
  lcd_wr_data(0x80);
  lcd_wr_data(0x88);
  lcd_wr_data(0x90);
  lcd_wr_data(0x98);
  lcd_wr_data(0xA0);
  lcd_wr_data(0xA7);
  lcd_wr_data(0xAF);
  lcd_wr_data(0xB6);
  lcd_wr_data(0xBE);
  lcd_wr_data(0xC7);
  lcd_wr_data(0xCE);
  lcd_wr_data(0xD6);
  lcd_wr_data(0xDE);
  lcd_wr_data(0xE6);
  lcd_wr_data(0xEF);
  lcd_wr_data(0xF5);
  lcd_wr_data(0xFB);
  lcd_wr_data(0xFC);
  lcd_wr_data(0xFE);
  lcd_wr_data(0x8C);
  lcd_wr_data(0xA4);
  lcd_wr_data(0x19);
  lcd_wr_data(0xEC);
  lcd_wr_data(0x1B);
  lcd_wr_data(0x4C);
  lcd_wr_data(0x40);

  uint8_t i;
  lcd_wr_command(0x2D);         //HX8369A_COLOUR_SET
  for (i=0; i<=63; i++)
  {
    lcd_wr_data(i*8);   
  }

  for (i=0; i<=63; i++)
  {
    lcd_wr_data(i*4);   
  }

  for (i=0; i<=63; i++)
  {
    lcd_wr_data(i*8);   
  }

  lcd_wr_command(0x35); //HX8369A_SET_TEAR_ON
        lcd_wr_data(0x55);

  lcd_wr_command(0x3A); //HX8369A_SET_PIXEL_FORMAT
        lcd_wr_data(0x55);

        lcd_wr_command(0x11); //HX8369A_EXIT_SLEEP_MODE
        delay_ms(120);
        lcd_wr_command(0x29); //HX8369A_SET_DISPLAY_ON
               
       
        lcd_wr_command(0x2A); //Partial Display Setting
        lcd_wr_data(0x00);
        lcd_wr_data(0x00);
        lcd_wr_data(0x01);
        lcd_wr_data(0xDF);
       
        lcd_wr_command(0x2B);
        lcd_wr_data(0x00);
        lcd_wr_data(0x00);
        lcd_wr_data(0x03);
        lcd_wr_data(0x1F);
       
        lcd_wr_command(0x2C);
  /* HX8369A Init Code END */

  TFT_BL_VAL(50);             //开启背光50%亮度
}


以上是XMC和HX8369A的初始化代码,求大佬看看设置是否有错误的地方。


使用特权

评论回复
沙发
天残梦| | 2023-12-6 18:29 | 只看该作者
这种问题,除了你的领导以及关系很要好的个别同事,几乎不会有人帮你看代码

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

6

主题

87

帖子

1

粉丝