硬件准备
ADSP-EDU-BF533:BF533开发板
AD-HP530ICE:ADI DSP仿真器
软件准备
Visual DSP++软件
硬件链接
EBIU总线LCD屏
硬件实现原理
LCD2.4 寸液晶屏子卡板连接在 ADSP-EDU-BF53x 开发板的扩展端口 PORT1 和 PORT2 上,板卡插入时,应将扩展子卡板上标注的“圆圈”符号与板卡上的“圆圈”对准插入,避免子卡板反向接入板卡。
LCD2.4 寸液晶屏子卡板采用 EBIU 接口的液晶屏,液晶屏型号为 ILI9325。和通用的 TFT 液晶屏不同,TFT 液晶屏在显示时,需要处理器对其不断的送入数据,一旦数据中断,液晶屏上将出现花屏。而 ILI9325 液晶屏内部有
维持液晶屏持续显示的缓存,只需通过 EBIU 接口送入一帧图像的数据后,液晶屏将持续显示该数据图片,无需处理器不断刷新维持。
ILI9325 为 2.4 寸 240*320RGB 格式 26 万色的液晶屏,支持 MPU,SPI,RGB 三种总线接口。MPU 接口即 i80处理器总线接口,支持 8/9/16/18 位总线宽度。SPI 接口为串行外设接口。RGB 接口是常用的包含行场同步信号的视频接口。
BF53X 板卡的 EBIU 接口符合 ILI9325 液晶屏 MPU 接口的标准。在 BF53X 处理器上,因为只有一个 PPI 接口,在做视频处理时,摄像头和液晶屏共用 1 个 PPI 接口,使得无法实现实时采集显示功能。采用 ILI9325 液晶屏,将
其连接在 EBIU 接口上,这样摄像头通过 PPI 接口采集数据,然后将数据处理后,通过 EBIU 接口送到液晶屏上,就可以实现实时的采集和显示的功能。
ILI9325 采用扩展接口的 EBIU 接口连接,扩展接口 EBIU 接口片选由 CPLD 映射,其映射寄存器为:
#define pEXT_CS (volatile unsigned short *)0x203A0000
ILI9325 液晶屏的命令和数据控制接口,映射在 BF53X 处理器 EBIU 接口的地址线 A3 上,通过 A3 地址线的高
低电平来告知液晶屏当前操作是命令操作还是数据操作。
当 A3 为 1 时,为数据操作
当 A3 为 0 时,为命令操作
为方便使用,将对液晶屏操作的寄存器重新做了映射:
#define pEXT_CS_DAT (volatile unsigned short *)0x203A0008
#define pEXT_CS_CMD (volatile unsigned short *)0x203A0000
访问上面的寄存器,A3 地址线会根据映射的地址进行 0 和 1 电平的切换,达到通过映射地址控制液晶屏的功能。
硬件连接示意图
代码实现功能
代码实现了通过 include 载入一张测试的图片数据到内存,数据格式为 240*320,RGB24。运行代码后,代码对ILI9325 初始化,然后将 RGB24 格式的数据转为 RGB565 格式,转完后将数据通过 EBIU 接口,送入液晶屏。执行代码后,在液晶屏上可以看到一幅图片。
测试步骤
1. 将仿真器(ICE)与 ADSP-EDU-BF53x 开发板和计算机连接好,将 LCD-24 子卡板按板上“圆圈”符号提示,插入板卡的 PORT1 和 PORT2 接口。
2. 先给 ADSP-EDU-BF53x 开发板上电,再为仿真器(ICE)上电。
3. 运行 VisualDSP++ 5.0 软件,选择合适的 BF53x 的 session 将仿真器与软件连接。
4. 加载 VisualDSP++ 5.0 工程文件 BF53x_LCD24.dpj 文件,编译并全速运行。
测试结果
代码运行完成后,会在液晶屏端看到一幅图像。
程序源码
9325.c
#include <cdefBF533.h>
#include <ccblkfn.h>
#include “cpld.h”
//============================================================
//根据芯片资料定义
#define WINDOW_XADDR_START 0x0050 // Horizontal Start Address Set
#define WINDOW_XADDR_END 0x0051 // Horizontal End Address Set
#define WINDOW_YADDR_START 0x0052 // Vertical Start Address Set
#define WINDOW_YADDR_END 0x0053 // Vertical End Address Set
#define GRAM_XADDR 0x0020 // GRAM Horizontal Address Set
#define GRAM_YADDR 0x0021 // GRAM Vertical Address Set
#define GRAMWR 0x0022 // memory write
//====================================================//
//函数声明
void ILI9325_Initial(void);
void Write_Cmd_Data(unsigned char x, unsigned int y);
void Write_Cmd(unsigned char DH,unsigned char DL);
void Write_Data(unsigned char DH,unsigned char DL);
void delays(unsigned int tt);
void Write_Data_U16(unsigned int y);
void LCD_SetPos(unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1);
void ClearScreen(unsigned int bColor);
void Show_RGB (unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1,unsigned int Color);
void LCD_PutString(unsigned short x, unsigned short y, char *s, unsigned int fColor, unsigned int bColor);
void Write_pic(unsigned short Cow_num,unsigned char *buffer)
{
int i;
LCD_SetPos(0,240,0,320);
for(i=0;i<76800;i++)
{
Write_Data(buffer[2i+1],buffer[2i]);
}
}
//===============================================================
//写命令数据
void Write_Cmd_Data (unsigned char x,unsigned int y)
{
unsigned char m,n;
m=y>>8;
n=y;
Write_Cmd(0x00,x);
Write_Data(m,n);
}
//====================== 写命令 ==========================//
void Write_Cmd(unsigned char DH,unsigned char DL)
{
*pEXT_CS_CMD = DH;
*pEXT_CS_CMD = DL;
}
//===================== 写数据 ===========================//
void Write_Data(unsigned char DH,unsigned char DL)
{
*pEXT_CS_DAT = DH;
*pEXT_CS_DAT = DL;
}
//============================================================
//延时程序
void delays(unsigned int count)
{
int i,j;
for(i=0;i<count;i++)
{
for(j=0;j<260;j++);
}
}
//=============================================================
//液晶初始化
void ILI9325_Initial(void)
{
delays(50);
Write_Cmd_Data(0x0001,0x0100);
Write_Cmd_Data(0x0002,0x0700);
Write_Cmd_Data(0x0003,0x1030);
Write_Cmd_Data(0x0004,0x0000);
Write_Cmd_Data(0x0008,0x0207);
Write_Cmd_Data(0x0009,0x0000);
Write_Cmd_Data(0x000A,0x0000);
Write_Cmd_Data(0x000C,0x0000);
Write_Cmd_Data(0x000D,0x0000);
Write_Cmd_Data(0x000F,0x0000);
//power on sequence VGHVGL
Write_Cmd_Data(0x0010,0x0000);
Write_Cmd_Data(0x0011,0x0007);
Write_Cmd_Data(0x0012,0x0000);
Write_Cmd_Data(0x0013,0x0000);
//vgh
Write_Cmd_Data(0x0010,0x1290);
Write_Cmd_Data(0x0011,0x0227);
//vregiout
Write_Cmd_Data(0x0012,0x001d); //0x001b
//vom amplitude
Write_Cmd_Data(0x0013,0x1500);
//vom H
Write_Cmd_Data(0x0029,0x0018);
Write_Cmd_Data(0x002B,0x000D);
//gamma
Write_Cmd_Data(0x0030,0x0004);
Write_Cmd_Data(0x0031,0x0307);
Write_Cmd_Data(0x0032,0x0002);// 0006
Write_Cmd_Data(0x0035,0x0206);
Write_Cmd_Data(0x0036,0x0408);
Write_Cmd_Data(0x0037,0x0507);
Write_Cmd_Data(0x0038,0x0204);//0200
Write_Cmd_Data(0x0039,0x0707);
Write_Cmd_Data(0x003C,0x0405);// 0504
Write_Cmd_Data(0x003D,0x0F02);
//ram
Write_Cmd_Data(0x0050,0x0000);
Write_Cmd_Data(0x0051,0x00EF);
Write_Cmd_Data(0x0052,0x0000);
Write_Cmd_Data(0x0053,0x013F);
Write_Cmd_Data(0x0060,0xA700);
Write_Cmd_Data(0x0061,0x0001);
Write_Cmd_Data(0x006A,0x0000);
//
Write_Cmd_Data(0x0080,0x0000);
Write_Cmd_Data(0x0081,0x0000);
Write_Cmd_Data(0x0082,0x0000);
Write_Cmd_Data(0x0083,0x0000);
Write_Cmd_Data(0x0084,0x0000);
Write_Cmd_Data(0x0085,0x0000);
//
Write_Cmd_Data(0x0090,0x0010);
Write_Cmd_Data(0x0092,0x0600);
Write_Cmd_Data(0x0093,0x0003);
Write_Cmd_Data(0x0095,0x0110);
Write_Cmd_Data(0x0097,0x0000);
Write_Cmd_Data(0x0098,0x0000);
Write_Cmd_Data(0x0007,0x0133);
}
//===============================================================
//定义坐标
static void LCD_SetPos(unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1)
{
Write_Cmd_Data(WINDOW_XADDR_START,x0);
Write_Cmd_Data(WINDOW_XADDR_END,x1);
Write_Cmd_Data(WINDOW_YADDR_START,y0);
Write_Cmd_Data(WINDOW_YADDR_END,y1);
Write_Cmd_Data(GRAM_XADDR,x0);
Write_Cmd_Data(GRAM_YADDR,y0);
Write_Cmd (0x00,0x22);
}
cpu.c
#include <cdefBF533.h>
void Init_SDRAM(void)
{
*pEBIU_SDRRC = 0x00000817;
*pEBIU_SDBCTL = 0x00000013;
*pEBIU_SDGCTL = 0x0091998d;
ssync();
}
void Init_EBIU(void)
{
*pEBIU_AMBCTL0 = 0x7bb07bb0;
*pEBIU_AMBCTL1 = 0x7bb07bb0;
*pEBIU_AMGCTL = 0x000f;
}
void Set_PLL(int pmsel,int pssel)
{
int new_PLL_CTL;
*pPLL_DIV = pssel;
asm(“ssync;”);
new_PLL_CTL = (pmsel & 0x3f) << 9;
*pSIC_IWR |= 0xffffffff;
if (new_PLL_CTL != *pPLL_CTL)
{
*pPLL_CTL = new_PLL_CTL;
asm(“ssync;”);
asm(“idle;”);
}
}
main.c
#include <cdefBF533.h>
#include <ccblkfn.h>
#include <stdio.h>
section(“sdram0_bank1”) unsigned char load_buffer[230400]=
{
#include “lcd24.dat”
};
section(“sdram0_bank1”) unsigned char dst[153600];
void main(void)
{
int i,j;
int m=0,n=0,line=0;
Set_PLL(16,4);
Init_EBIU();
Init_SDRAM();
ILI9325_Initial();
delays(20000);
for (n = 0; n < 230400; n += 3)
{
dst[m+1] = load_buffer[n+2] &0xf8; //B
dst[m+1] |= ((load_buffer[n+1]>>5) & 0x07); //GH
dst[m] = ((load_buffer[n+1]<<3) & 0xe0); //GL
dst[m] |= ((load_buffer[n]>>3) &0x1f); //R
m += 2;
}
Write_pic(line,dst);
delays(100000);
while(1);
}