单片机与RA8875接法及软件初始化之一(通过8080接口介绍)
作者:david 发表日期:2020-10-16 来源: 浏览:
本篇文章主要介绍8080时序驱动RA8875
RA8875 是一个文字与绘图模式的双图层液晶显示 (TFT-LCD) 控制器,可结合文字或2D图形应用,最大
可支持到800*480 点分辨率的中小尺寸数字面板。内建 768KB 显示内存可提供大多数使用者的应用一个
更弹性的解决方案。此外,使用者可藉由选用外部串行式Flash 接口,支持BIG5/GB 编码,可提供最大达
32*32 像素之的字型输入。在图形的使用上, RA8875 支持2D 的BTE 引擎 (Block Transfer Engine),此
功能兼容于一般通用的2D BitBLT 功能,可处理大量图形数据转换与传送。同时RA8875 也内建几何图形
加速引擎 (Geometric Speed-up Engine),提供使用者透过简单的设定轻松画出直线、矩形、圆形和椭圆
的几何图形。为了贴近终端始用者的应用, RA8875 整合了强大的功能,如画面卷动功能、显示浮动窗
口、图形Pattern 及文字放大等功能,可大量节省使用者软件开发的时间,并提升MCU软件的执行效率。
RA8875 提供低成本的 8080/6800 并列式MCU 接口,由于内建强大的硬件加速功能,可降低数据传输所
需的时间并且改善效率。 RA8875提供串行式 SPI/I2C 等极少量脚位的界面,内建 4-wire 的触控面板控制
器,以及2组脉波宽度调变 (PWM) ,可用于调整面板背光或其它应用。相对于其它的解决方案, RA8875
是一个功能强大及低成本的彩色TFT 控制器,让使用者顺利解决软硬件开发上的疑虑,同时达成低成本、高效能的系统方案。
一、硬件设计
连接DB[15:0]、CS、WE、RD等信号线。
选择通讯时序时,硬件电路两个脚位需要设定,本篇文章以8080时序讲解,所以C86和PS引脚都接地
XI\XO为内部晶体振荡电路的输入及输出端,用来连接外部晶体振荡器,以产生RA885的内部频率信号,晶体振荡器选取范围为15MHZ~30MHZ(建议可接20MHZ)
二、软件设计
1、单片机FSMC初始化
void FSMC_LCD_Init(void)
{FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; //初始化结构体FSMC_NORSRAMTimingInitTypeDef readWriteTiming; //时序结构体/*使能FSMC外设时钟*/RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC,ENABLE);//地址建立时间(ADDSET)具体实验测试进行设置readWriteTiming.FSMC_AddressSetupTime = 0x00;//数据保持时间(DATAST)readWriteTiming.FSMC_DataSetupTime = 0x03;//地址保持时间(ADDHLD)模式B未用到readWriteTiming.FSMC_AddressHoldTime = 0x00;//设置总线转换周期,仅用于复用模式的NOR操作readWriteTiming.FSMC_BusTurnAroundDuration = 0x00;//设置时钟分频,仅用于同步类型的存储器readWriteTiming.FSMC_CLKDivision = 0x00;//数据保持时间,仅用于NORreadWriteTiming.FSMC_DataLatency = 0x00;//选择匹配SRAM的模式readWriteTiming.FSMC_AccessMode = FSMC_AccessMode_A;// 选择FSMC映射的存储区域: Bank1 NORSRAMxFSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_BANK_NORSRAMx;//设置地址总线与数据总线是否复用,仅用于NORFSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;//设置要控制的存储器类型:NOR类型FSMC_NORSRAMInitStructure.FSMC_MemoryType =FSMC_MemoryType_NOR;//存储器数据宽度:16位FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;//设置是否使用突发访问模式,仅用于同步类型的存储器FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode =FSMC_BurstAccessMode_Disable;//设置是否使能等待信号,仅用于同步类型的存储器FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait=FSMC_AsynchronousWait_Disable;//设置等待信号的有效极性,仅用于同步类型的存储器FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;//设置是否支持把非对齐的突发操作,仅用于同步类型的存储器FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;//设置等待信号插入的时间,仅用于同步类型的存储器FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;//存储器写使能FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;//不使用等待信号FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;// 不使用扩展模式,读写使用相同的时序FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;//突发写操作FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;//读写时序配置FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readWriteTiming;//读写同样时序,使用扩展模式时这个配置才有效FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &readWriteTiming;FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); //初始化FSMC配置FSMC_NORSRAMCmd(FSMC_BANK_NORSRAMx, ENABLE); // 使能BANK}
2、写入命令及写入数据
#define ILI9341_CMD_ADDR (__IO uint16_t*)(0x60000000)#define ILI9341_DATA_ADDR (__IO uint16_t*)(0x60020000) //此处写入命令及数据地址根据硬件连接的地址线修改__inline void ILI9341_Write_Cmd ( uint16_t usCmd )
{*ILI9341_CMD_ADDR = usCmd;}__inline void ILI9341_Write_Data ( uint16_t usData ){* ILI9341_DATA_ADDR = usData;}
3、8875初始化及液晶屏的相关初始化(以AT070TN92为例)
GPIO_ResetBits(GPIOE, GPIO_Pin_1);Delay(0xAFF);GPIO_SetBits(GPIOE, GPIO_Pin_1 ); //软件复位Delay(0xAFF);//RA8875_PLL_iniLCD_CmdWrite(0x88);LCD_DataWrite(0x0b);delay_ms(1);LCD_CmdWrite(0x89);LCD_DataWrite(0x02);delay_ms(1);LCD_CmdWrite(0x10); //SYSR bit[4:3]=00 256 color bit[2:1]= 00 8bit MPU interface//LCD_DataWrite(0x000c); // if 8bit MCU interface and 65k color displayLCD_DataWrite(0x0F); // if 16bit MCU interface and 65k color displaydelay_us(1);LCD_CmdWrite(0x04); //PCLK inverseLCD_DataWrite(0x81);delay_ms(1);//Horizontal setLCD_CmdWrite(0x14); //HDWR//Horizontal Display Width Setting Bit[6:0]LCD_DataWrite(0x63);//Horizontal display width(pixels) = (HDWR + 1)*8LCD_CmdWrite(0x15); //Horizontal Non-Display Period Fine Tuning Option Register (HNDFTR)LCD_DataWrite(0x03);//Horizontal Non-Display Period Fine Tuning(HNDFT) [3:0]LCD_CmdWrite(0x16); //HNDR//Horizontal Non-Display Period Bit[4:0]LCD_DataWrite(0x03);//Horizontal Non-Display Period (pixels) = (HNDR + 1)*8LCD_CmdWrite(0x17); //HSTR//HSYNC Start Position[4:0]LCD_DataWrite(0x02);//HSYNC Start Position(PCLK) = (HSTR + 1)*8LCD_CmdWrite(0x18); //HPWR//HSYNC Polarity ,The period width of HSYNC.LCD_DataWrite(0x00);//HSYNC Width [4:0] HSYNC Pulse width(PCLK) = (HPWR + 1)*8//Vertical setLCD_CmdWrite(0x19); //VDHR0 //Vertical Display Height Bit [7:0]LCD_DataWrite(0xdf);//Vertical pixels = VDHR + 1LCD_CmdWrite(0x1a); //VDHR1 //Vertical Display Height Bit [8]LCD_DataWrite(0x01);//Vertical pixels = VDHR + 1LCD_CmdWrite(0x1b); //VNDR0 //Vertical Non-Display Period Bit [7:0]LCD_DataWrite(0x14);//Vertical Non-Display area = (VNDR + 1)LCD_CmdWrite(0x1c); //VNDR1 //Vertical Non-Display Period Bit [8]LCD_DataWrite(0x00);//Vertical Non-Display area = (VNDR + 1)LCD_CmdWrite(0x1d); //VSTR0 //VSYNC Start Position[7:0]LCD_DataWrite(0x06);//VSYNC Start Position(PCLK) = (VSTR + 1)LCD_CmdWrite(0x1e); //VSTR1 //VSYNC Start Position[8]LCD_DataWrite(0x00);//VSYNC Start Position(PCLK) = (VSTR + 1)LCD_CmdWrite(0x1f); //VPWR //VSYNC Polarity ,VSYNC Pulse Width[6:0]LCD_DataWrite(0x01);//VSYNC Pulse Width(PCLK) = (VPWR + 1)LCD_CmdWrite(0xf2);LCD_DataWrite(0x01);//Active window set//setting active window XLCD_CmdWrite(0x30); //Horizontal Start Point 0 of Active Window (HSAW0)LCD_DataWrite(0x00); //Horizontal Start Point of Active Window [7:0]//delay_us(1);LCD_CmdWrite(0x31); //Horizontal Start Point 1 of Active Window (HSAW1)LCD_DataWrite(0x00); //Horizontal Start Point of Active Window [9:8]//delay_us(1);LCD_CmdWrite(0x34); //Horizontal End Point 0 of Active Window (HEAW0)LCD_DataWrite(0x1F); //Horizontal End Point of Active Window [7:0]//delay_us(1);LCD_CmdWrite(0x35); //Horizontal End Point 1 of Active Window (HEAW1)LCD_DataWrite(0x03); //Horizontal End Point of Active Window [9:8]//delay_us(1);//setting active window YLCD_CmdWrite(0x32); //Vertical Start Point 0 of Active Window (VSAW0)LCD_DataWrite(0x00); //Vertical Start Point of Active Window [7:0]//delay_us(1);LCD_CmdWrite(0x33); //Vertical Start Point 1 of Active Window (VSAW1)LCD_DataWrite(0x00); //Vertical Start Point of Active Window [8]//delay_us(1);LCD_CmdWrite(0x36); //Vertical End Point of Active Window 0 (VEAW0)LCD_DataWrite(0xdf); //Vertical End Point of Active Window [7:0]//delay_us(1);LCD_CmdWrite(0x37); //Vertical End Point of Active Window 1 (VEAW1)LCD_DataWrite(0x01); //Vertical End Point of Active Window [8]// /*setting RA8875 display on*/LCD_CmdWrite(0x01); //LCD_DataWrite(0x80); //delay_ms(20);/*RA8875 DMA function setting*/SROM_CLK_DIV(0); //set serial interface clock rateSerial_ROM_select1();Select_Serial_Waveform_mode3();SERIAL_ROM_Read_Cycle_5bus();SERIAL_ROM_DMA_mode();SERIAL_ROM_Signal_mode();DMA_Block_mode();/*setting RA8875 memory clear with active window*/Clear_Active_Window();/*setting backlight on RA8875 PWM1 control*/PWM1_enable();PWM1_fnuction_sel();PWM1_clock_ratio(0x02); //bit0~3 58KHZPWM1_duty_cycle(0xff); //Brightness_level=10;LCD_Clear(0x001f);//
注:RA8875色彩深度 可为256/65K 色,最大支持到800*480.
分享到: