单片机/MCU论坛
直播中

harchy

12年用户 53经验值
擅长:光电显示 控制/MCU
私信 关注

单片机驱动彩屏最简方案:单片机_RA8889最小开发板驱动控制TFT彩屏介绍(一)

本文介绍使用单片机+RA8889来驱动和控制彩屏的最小方案。文章从RA8889的架构功能、硬件电路设计及软件设计三个方面来说明。

小编已发布多篇文章介绍了 单片机+RA8889来驱动控制彩屏 ,但是仍有不少单片机玩家可能对驱动彩屏还不算熟悉,在此加推一个短篇介绍系列,阅读时间不会超过半小时,定能揭开您的疑惑!

本系列文章最后一篇会有彩蛋释放,敬请跟踪阅读。

一、RA8889的硬件架构图示

此处仍不嫌啰嗦,再作一下架构说明,参下图:
RA8889方框图_new.png

主要特色:

  • 解码:JPG,AVI;支持BMP,PNG图片
  • 可外接4颗FLASH,支持Q-SPI通信模式
  • 图片显示采用DMA,不使用MCU资源
  • MCU接口丰富:8080/6800,SPI-3/4,I2C
  • 支持分辨率:最大1366 x [理论上不限高度]
  • LQFP-100封装
  • 工作温度-40~85℃

二、UI设计时重点

UI上所用到的图片、自建字库预先烧录到FLASH中,图片可以是整图,也可以是小图。

RA8889是直接从FLASH寻址读取图片、字库数据,并显示到相应的位置,可以是局部更新图片,也可以是满屏替换,相当灵活高效。

MCU只发送相应的API指令即可,提供给RA8889进行自动寻址及放置图片,指令简单,MCU会节约许多资源,即使使用SPI方式也可以得到十分快速度的画面切换。

RA8889内建绘图函数以及图形处理(剔除底色、文字上色、图片叠加运算等),基础图形处理简单快速高效。

UI界面要显示的字母,可以调用RA8889内建的字符,显示数度快,内建字符可放大1~4倍(向量放大)。

三、对FLASH容量的需求

RA8889支持JPG格式,多数UI界面可以采用JPG图片,因此FLASH容量可以很小。

可以 自建全套汉字字库 ,比如24x24,32x32点,字库不大,可以打包存入FLASH,再利用RA8889的DMA读取,结合芯片BTE算法,可快速显示汉字。

RA8889可外接扩展4颗FLASH,一般采用NOR。一般UI设计时使用到1~2颗是够用,更何况支持JPG格式,图片容量需求更小了。

注意:请将FLASH扩展到RA8889使用,才能发挥出这颗控制芯片的优势。而不是扩展到单片机喔!将FLASH扩展到单片机使用时会大打折扣。

四、显存

RA8889内建128Mbits显存,用户可自由规划画布、图像,显存相当充裕,UI界面,需要叠放许多背景图片、图标、菜单图片等等,预先放进缓冲层,需要时直接使用BTE Memory Copy是十分方便快速。

同时也可以直接切换主界面到其它图层,切换效果可做到 零延时 ,这个是缓存大的优点。

许多单片机玩家直接驱动串口屏,反应最大的问题是刷新慢,若用RA8889这颗芯片来驱动控制彩屏,这个问题是不存在的。

五、能做到什么效果

显示UI,简单的界面已无法满足用户群对产品的期待了,通过RA8889,完全可以将界面做得更加美观、生动、大气,同时还能加进动画效果,这一切只要使用一颗51单片机就能做得到!

六、应用举例

  1. 咖啡机控制屏
  2. 汽车仪表盘
  3. 电力、安防仪表
  4. 各种医疗器械仪表盘
  5. 自动化控制仪表盘
  6. 串口屏

来吧!只要一颗51单片机,就能点亮彩色的视窗!

回帖(4)

harchy

2024-8-23 21:44:24

本篇介绍电路设计。底部可下载参考电路。

一、硬件样板:

样品图_min.jpg

该板需要外接MCU,图示接法为SPI-4线。

可接AT043TN25和AT070TN92,及兼容接口的屏。

二、RA8889芯片引脚定义

1.png

再上一张引脚简化图,概览引脚结构:
RA8889引脚简图_water.png

电路中没有画MCU,需外接,采用何种接口方式,可通过PS2~0来选择。最简单的话SPI-3/4线即可。

RA8889各个VCC和LDO(1.2V)引脚均需要接旁路电容进行滤波,且放置距离芯片引脚要近一些。

三、FLASH

RA8889可外接4颗FLASH,一般建议使用NOR FLASH,基本够用了:
FLASH.png

该设计中仅接出两颗FLASH,RA8889有两路BUS总线,每路总线可扩展2个片选,故总共可外接4颗FLASH。

FLASH是用于存放UI界面的图资,可以采用JPG格式存入,支持BMP、JPG、PNG、AVI影片,用户根据需要选择。

FLASH引脚需要上拉,一是扩展比较多颗负载重,二是在烧录时会吃多一些电流。

四、液晶屏接口

lcd链接器.png

输出的TTL串联22欧姆电阻,是为了降低EMC而加。

输出配置两种接口,40PIN和50PIN,常用的4.3寸采用40PIN,7寸采用50PIN。

五、FLASH烧录口的设计

flash外接链接器.png

FLASH外接线进行烧录,烧录器采用CH341A即可,便宜易买。该接口引出2路BUS总线,烧录时TEST1跳线至3.3V,正常工作时取下跳线。

另外将PS2~0跳线口也放置到该连接器,通过跳线帽便于改变MCU的通信方式。

六、5V转3.3V电路

5-3v.png

采用通用的1117-3.3芯片即可,注意芯片周围的覆铜,以便散热。

七、5V转LED背光

LED背光.png

背光是整个电路功耗最大的一块,注意电感L2和肖特基二极管D1的覆铜,便以散热。适当调整反馈电阻R11//R12,以防电流过大,零件过热。

可以接上R9,通过RA8889的PWM0输出方波调整背光亮度。

八、LCD驱动电压

LCD升压.png

这部份功耗不大,主要是提供LCD的驱动电压,不太吃电流。

4.3寸的话不需要加这部分电路;AT070TN92则需要外加驱动电压,看是繁琐,其实和LED的升压电路大同小异。

焊接时要注意齐纳二极管D3和D6的方向,一个负压,一个正压。

九、关于地线

Layout走线时,注意电源的地单独走线、覆铜,主要是升压、和降压电路,数字地单独走线、覆铜,最终在滤波电容附近收到一起。这样做可极大地预防电源杂讯对数字电路的干扰。

本章完

举报

harchy

2024-8-23 22:03:12

参考电路图下载:
*附件:RT8889CNN03_v1.0.pdf

举报

harchy

2024-9-5 13:54:49

单片机驱动彩屏最简方案:单片机_RA8889最小开发板驱动控制TFT彩屏介绍(三)软件设计

本篇介绍软件设计,相关代码请从本人相关文章获取,已上传多种参考代码,大同小异。

一、老样子,先上一张软件代码导图:

代码三步曲:

  • 设定通信方式(已写好各种通信方式的参考代码了);
  • 初始化RA8889,如上图所示,看似很多,代码都是直接调用API函数;
  • 调用API函数进行界面设计,对于工业上所使用的UI,这些API足够用,也十分简洁!

二、代码要点:

1. 一些宏定义请先修改,在userdef.h
(1)显存规划:

/* RA8889显存和显示配置 */
#define canvas_image_width  1600		//画布宽度,设定为屏宽的n倍
#define main_image_width  1600			//图像宽度,设定为屏宽的n倍
#define LCD_Width  800 
#define LCD_Height  480

(2)主频配置,一般只修改SCAN_FREQ即可

/* RA8889频率配置 */
#define OSC_FREQ	10			//晶振频率,外接晶振请使用10MHz
#define DRAM_FREQ	133			//SDRAM刷新频率,最高166MHz
#define CORE_FREQ	120			//RA8889核心频率,最高133MHz 
#define SCAN_FREQ	30			//PCLK液晶扫描频率,最高100MHz

(3)液晶屏型号定义,最终是在初始化中Set_LCD_Panel();执行,不同液晶屏配置不同,许多RD还不熟悉彩屏,这里先卖个关子,待后续文章另起新篇针对该项专门介绍。

下方为AT070TN92的液晶屏参数配置:

#ifdef L80480R70

	//**[10h]**//
	Select_LCD_Sync_Mode();	// Enable XVSYNC, XHSYNC, XDE.
//	Select_LCD_DE_Mode();	// XVSYNC & XHSYNC in idle state.
	
	PCLK_Falling();
//	PCLK_Rising();

	VSCAN_T_to_B();
	PDATA_Set_RGB();

	HSYNC_Low_Active();
	VSYNC_Low_Active();
	DE_High_Active();
//	DE_Low_Active();

	LCD_HorizontalWidth_VerticalHeight(800,480);
	LCD_Horizontal_Non_Display(64);
	LCD_HSYNC_Start_Position(208);
	LCD_HSYNC_Pulse_Width(24);
	LCD_Vertical_Non_Display(16);
	LCD_VSYNC_Start_Position(22);
	LCD_VSYNC_Pulse_Width(16);

#endif

下方为AT043TN25的液晶屏参数配置:

#ifdef AT043TN25

    //**[10h]**//
    //Select_LCD_Sync_Mode();	// Enable XVSYNC, XHSYNC, XDE.
    Select_LCD_DE_Mode(); // XVSYNC & XHSYNC in idle state.

    //	PCLK_Rising();
    PCLK_Falling();
    VSCAN_T_to_B();
    PDATA_Set_RGB();

    //**[13h]**//
    HSYNC_Low_Active();
    VSYNC_Low_Active();
    DE_High_Active();
    //	DE_Low_Active();
    //------------------------------------
    //**[14h][15h][1Ah][1Bh]**//
    LCD_HorizontalWidth_VerticalHeight(480, 272); // LCD Resolution 480x272。
    //**[16h][17h]**//
    LCD_Horizontal_Non_Display(38); // 480x272,HSYNC Back Porch=38。
    //**[18h]**//
    LCD_HSYNC_Start_Position(20); // 480x272 HSYNC Front Porch = 20。
    //**[19h]**//
    LCD_HSYNC_Pulse_Width(20); // 480x272,HSYNC Pulse Width=5~30,set 20。
    //**[1Ch][1Dh]**//
    LCD_Vertical_Non_Display(4); // 480x272,VSYNC Back Porch =4。
    //**[1Eh]**//
    LCD_VSYNC_Start_Position(15); // 480x272,VSYNC Front Porch =15。
    //**[1Fh]**//
    LCD_VSYNC_Pulse_Width(3); // 480x272,VSYNC Pulse Width =3。

#endif

参考演示程序已经预设各种分辨率的液晶屏参数配置,可以直接代入测试,再进行微调。使用上非常简单!

(4)MCU通信方式和显示色深定义:

/*==== MCU接口通信位数和显示色深定义 ====*/
//#define MCU_8bit_ColorDepth_8bpp
//#define MCU_8bit_ColorDepth_16bpp
#define MCU_8bit_ColorDepth_24bpp
//#define MCU_16bit_ColorDepth_16bpp
//#define MCU_16bit_ColorDepth_24bpp_Mode_1
//#define MCU_16bit_ColorDepth_24bpp_Mode_2
  1. 延时函数
    使用毫秒即可,请依照自己的MCU主频调整延时长度:
void delay_ms(unsigned int n);

三、进行UI界面设计

底层封装好API函数了,存放在RA8889_API.c(51单片机请改用RA8889_API_51.c),每个函数头均有用法说明,不明白请进函数查阅详细参数说明。并且所有代码透明,感兴趣的话请进入函数查看底层寄存器的设定。

UI界面基础三要素为 绘图、显示文字、显示图片, 这些都是RA8889硬件支持的功能,显示速度很快!如下列举主要的显示函数:

/* MCU直接写点,基础函数 */
void putPixel(unsigned short x,unsigned short y,unsigned long color);

/* 数据直接写显存 */
void MPU8_8bpp_Memory_Write (unsigned short x,unsigned short y,unsigned short w ,unsigned short h ,const unsigned char *data_array);
void MPU8_16bpp_Memory_Write (unsigned short x,unsigned short y,unsigned short w ,unsigned short h ,const unsigned char *data_array);
void MPU8_24bpp_Memory_Write (unsigned short x,unsigned short y,unsigned short w ,unsigned short h ,const unsigned char *data_array);
void MPU16_16bpp_Memory_Write (unsigned short x,unsigned short y,unsigned short w ,unsigned short h ,const unsigned short *data_array);
void MPU16_24bpp_Mode1_Memory_Write (unsigned short x,unsigned short y,unsigned short w ,unsigned short h ,const unsigned short *data_array);
void MPU16_24bpp_Mode2_Memory_Write (unsigned short x,unsigned short y,unsigned short w ,unsigned short h ,const unsigned short *data_array);

/* 绘图:各种几何图形(硬件实现,高速) */
void Draw_Line(unsigned long LineColor,unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2);
void Draw_Triangle(unsigned long ForegroundColor,unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned short X3,unsigned short Y3);
void Draw_Triangle_Fill(unsigned long ForegroundColor,unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned short X3,unsigned short Y3);
void Draw_Circle(unsigned long ForegroundColor,unsigned short XCenter,unsigned short YCenter,unsigned short R);
void Draw_Circle_Fill(unsigned long ForegroundColor,unsigned short XCenter,unsigned short YCenter,unsigned short R);
void Draw_Ellipse(unsigned long ForegroundColor,unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R);
void Draw_Ellipse_Fill(unsigned long ForegroundColor,unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R);
void Draw_Left_Up_Curve(unsigned long ForegroundColor,unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R);
void Draw_Left_Up_Curve_Fill(unsigned long ForegroundColor,unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R);
void Draw_Right_Down_Curve(unsigned long ForegroundColor,unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R);
void Draw_Right_Down_Curve_Fill(unsigned long ForegroundColor,unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R);
void Draw_Right_Up_Curve(unsigned long ForegroundColor,unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R);
void Draw_Right_Up_Curve_Fill(unsigned long ForegroundColor,unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R);
void Draw_Left_Down_Curve(unsigned long ForegroundColor,unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R);
void Draw_Left_Down_Curve_Fill(unsigned long ForegroundColor,unsigned short XCenter,unsigned short YCenter,unsigned short X_R,unsigned short Y_R);
void Draw_Square(unsigned long ForegroundColor,unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2);
void Draw_Square_Fill(unsigned long ForegroundColor,unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2);
void Draw_Circle_Square(unsigned long ForegroundColor,unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned short R,unsigned short Y_R);
void Draw_Circle_Square_Fill(unsigned long ForegroundColor,unsigned short X1,unsigned short Y1,unsigned short X2,unsigned short Y2,unsigned short R,unsigned short Y_R);

/* 内存操作:复制、运算、剔除底色、单色延展彩色、淡入淡出(硬件实现,快速) */
void BTE_Memory_Copy(unsigned long S0_Addr,unsigned short S0_W,unsigned short XS0,unsigned short YS0,unsigned long S1_Addr,unsigned short S1_W,unsigned short XS1,unsigned short YS1,unsigned long Des_Addr,unsigned short Des_W, unsigned short XDes,unsigned short YDes,unsigned int ROP_Code,unsigned short X_W,unsigned short Y_H);
void BTE_Memory_Copy_Chroma_key(unsigned long S0_Addr,unsigned short S0_W,unsigned short XS0,unsigned short YS0,unsigned long Des_Addr,unsigned short Des_W, unsigned short XDes,unsigned short YDes,unsigned long Background_color,unsigned short X_W,unsigned short Y_H);
void BTE_MCU_Write_MCU_8bit(unsigned long S1_Addr,unsigned short S1_W,unsigned short XS1,unsigned short YS1,unsigned long Des_Addr,unsigned short Des_W, unsigned short XDes,unsigned short YDes,unsigned int ROP_Code,unsigned short X_W,unsigned short Y_H,const unsigned char *data_array);
void BTE_MCU_Write_MCU_16bit(unsigned long S1_Addr,unsigned short S1_W,unsigned short XS1,unsigned short YS1,unsigned long Des_Addr,unsigned short Des_W, unsigned short XDes,unsigned short YDes,unsigned int ROP_Code,unsigned short X_W,unsigned short Y_H,const unsigned short *data_array);
void BTE_MCU_Write_Chroma_key_MCU_8bit(unsigned long Des_Addr,unsigned short Des_W, unsigned short XDes,unsigned short YDes,unsigned long Background_color,unsigned short X_W,unsigned short Y_H,const unsigned char *data_array);
void BTE_MCU_Write_Chroma_key_MCU_16bit(unsigned long Des_Addr,unsigned short Des_W, unsigned short XDes,unsigned short YDes,unsigned long Background_color,unsigned short X_W,unsigned short Y_H,const unsigned short *data_array);
void BTE_Memory_Copy_ColorExpansion(unsigned long S0_Addr,unsigned short S0_W,unsigned short XS0,unsigned short YS0,unsigned long Des_Addr,unsigned short Des_W, unsigned short XDes,unsigned short YDes,unsigned short X_W,unsigned short Y_H,unsigned long Foreground_color,unsigned long Background_color);
void BTE_Memory_Copy_ColorExpansion_Chroma_key(unsigned long S0_Addr,unsigned short S0_W,unsigned short XS0,unsigned short YS0,unsigned long Des_Addr,unsigned short Des_W, unsigned short XDes,unsigned short YDes,unsigned short X_W,unsigned short Y_H,unsigned long Foreground_color);
void BTE_MCU_Write_ColorExpansion_MCU_8bit(unsigned long Des_Addr,unsigned short Des_W, unsigned short XDes,unsigned short YDes,unsigned short X_W,unsigned short Y_H,unsigned long Foreground_color,unsigned long Background_color,const unsigned char *data_array);
void BTE_MCU_Write_ColorExpansion_MCU_16bit(unsigned long Des_Addr,unsigned short Des_W, unsigned short XDes,unsigned short YDes,unsigned short X_W,unsigned short Y_H,unsigned long Foreground_color,unsigned long Background_color,const unsigned short *data_array);
void BTE_MCU_Write_ColorExpansion_Chroma_key_MCU_8bit(unsigned long Des_Addr,unsigned short Des_W, unsigned short XDes,unsigned short YDes,unsigned short X_W,unsigned short Y_H,unsigned long Foreground_color,const unsigned char *data_array);
void BTE_MCU_Write_ColorExpansion_Chroma_key_MCU_16bit(unsigned long Des_Addr,unsigned short Des_W, unsigned short XDes,unsigned short YDes,unsigned short X_W,unsigned short Y_H,unsigned long Foreground_color,const unsigned short *data_array);
void BTE_Pattern_Fill(unsigned char P_8x8_or_16x16, unsigned long S0_Addr,unsigned short S0_W,unsigned short XS0,unsigned short YS0,unsigned long S1_Addr,unsigned short S1_W,unsigned short XS1,unsigned short YS1,unsigned long Des_Addr,unsigned short Des_W, unsigned short XDes,unsigned short YDes,unsigned int ROP_Code,unsigned short X_W,unsigned short Y_H);
void BTE_Pattern_Fill_With_Chroma_key(unsigned char P_8x8_or_16x16 ,unsigned long S0_Addr,unsigned short S0_W,unsigned short XS0,unsigned short YS0,unsigned long S1_Addr,unsigned short S1_W,unsigned short XS1,unsigned short YS1,unsigned long Des_Addr,unsigned short Des_W, unsigned short XDes,unsigned short YDes,unsigned int ROP_Code,unsigned long Background_color,unsigned short X_W,unsigned short Y_H);
void BTE_Solid_Fill(unsigned long Des_Addr,unsigned short Des_W, unsigned short XDes,unsigned short YDes,unsigned long Foreground_color,unsigned short X_W,unsigned short Y_H);
void BTE_Alpha_Blending_Picture_Mode(unsigned long S0_Addr,unsigned short S0_W,unsigned short XS0,unsigned short YS0,unsigned long S1_Addr,unsigned short S1_W,unsigned short XS1,unsigned short YS1,unsigned long Des_Addr,unsigned short Des_W, unsigned short XDes,unsigned short YDes,unsigned short X_W,unsigned short Y_H,unsigned char alpha);

/* DMA功能,快速显示图片(JPG,BMP),播放AVI影片 */
void DMA_24bit(unsigned char Clk ,unsigned short X1,unsigned short Y1,unsigned short X_W,unsigned short Y_H ,unsigned short P_W ,unsigned long Addr);
void DMA_32bit(unsigned char Clk ,unsigned short X1,unsigned short Y1,unsigned short X_W,unsigned short Y_H ,unsigned short P_W,unsigned long Addr);
void JPG_NOR (unsigned long addr,unsigned long JPGsize,unsigned long IDEC_canvas_width,unsigned short x,unsigned short y);
void AVI_NOR(unsigned long addr,unsigned long videosize,unsigned long shadow_buffer_addr,unsigned long PIP_buffer_addr,unsigned long x,unsigned long y,unsigned long height,unsigned long width,unsigned long PIP_width);

四、彩蛋

我们已经开发好一款新的RA8889开发板,简单易用,使用您的单片机,通过并口或者串口直接连接即可,外接一片AT043TN25或者AT070TN92,只要接口兼容,通通都能点!
RA8889精简版:RA6809,该芯片仅提供SPI接口与MCU通信,但RT8889CNN03开发板.jpg
功能上和RA8889完全一样!更详细信息请关注我们的产品开发进展!

以下效果使用51单片机STC8H8K64U+RA6809开发板+1024x600/800x480彩屏进行演示:

举报

harchy

2024-10-17 15:14:03

STC8H8K64U单片机板+RA8889/RA6809开发板控制彩屏效果演示图:

有没有兴趣?来官方论坛来了解:单片机的视窗

RT8H8K001_RT6809CNN01_v1.2_min.jpg

举报

更多回帖

发帖
×
20
完善资料,
赚取积分