资源描述:
《SOPC技术及应用-1 ppt课件.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、4.6LCD控制器内核Optrex16207LCD控制器IP核为NiosII用户在Optrex16207LCD上显示字符提供硬件接口和软件驱动,用户可以将其视为一个字符模式的器件通过ANSIC的标准库函数来访问它。DE2平台上有一个16*2的LCD模块,LCD模块中内嵌ASCII码字库,也可以自定义字库。14.6.1LCD控制器内核概述LCD控制器Optrex16207LCD模块地址数据控制至片上逻辑的Avalon从接口ERSR/WDB0..DB72DE2平台LCD模块信号名称含义LCD_RWLCD读写选择信号,高电平读,低电
2、平写LCD_ENLCD使能信号LCD_RS数据/指令选择,高电平为数据,低电平为指令LCD_DATA[7:0]LCD数据信号LCD_ONLCD开关,控制LCD,高电平打开LCD显示LCD_BLONLCD背光开关,高电平打开LCD背光LCD控制器Optrex16207LCD模块地址数据控制至片上逻辑的Avalon从接口ERSR/WDB0..DB73476543210Offset+-----+-----+-----+-----+-----+-----+-----+-----+RS=0
3、CommandRegister(WRITE-O
4、nly)
5、0+-----+-----+-----+-----+-----+-----+-----+-----+RS=0
6、StatusRegister(READ-Only)
7、1+-----+-----+-----+-----+-----+-----+-----+-----+RS=1
8、DataRegister(WRITE-Only)
9、2+-----+-----+-----+-----+-----+-----+-----+-----+RS=1
10、DataRegister(READ-Only)
11、3+-----+-----+-----+-
12、----+-----+-----+-----+-----+5modulelcd_16207_0(//inputs:address,begintransfer,read,write,writedata,//outputs:LCD_E,LCD_RS,LCD_RW,LCD_data,readdata);outputLCD_E;outputLCD_RS;outputLCD_RW;inout[7:0]LCD_data;output[7:0]readdata;input[1:0]address;inputbegintransfer;inp
13、utread;inputwrite;input[7:0]writedata;wireLCD_E;wireLCD_RS;wireLCD_RW;wire[7:0]LCD_data;wire[7:0]readdata;endmoduleassignLCD_RW=address[0];assignLCD_RS=address[1];assignLCD_E=read
14、write;assignLCD_data=(address[0])?8'bz:writedata;assignreaddata=LCD_data;//control_sla
15、ve,whichisane_avalon_slave64.6.2软件编程模型altera_avalon_lcd_16207_regs.h文件定义了LCD控制器和寄存器映射,并提供访问底层硬件的符号常数;在hal目录中,altera_avalon_lcd_16207.c实现了LCD控制器的HAL系统库驱动。789用户可以通过ANSIC标准库函数来访问LCD,如printf()函数可以在Optrex16207LCD上显示字符。#include#include#include“system.h”
16、voidmain(){FILE*lcd;lcd=fopen(“/dev/lcd_16207_0”,“w”);fprintf(lcd,“””);fprintf(lcd,“NicetoSeeYou!”);fclose(lcd);}#defineALTERA_AVALON_LCD_16207_DEV_INSTANCE(name,d)staticaltera_avalon_lcd_16207_devd={{ALT_LLIST_ENTRY,name##_NAME,NULL,/*open*/NULL,/*cl
17、ose*/NULL,/*read*/altera_avalon_lcd_16207_write_fd,NULL,/*lseek*/NULL,/*fstat*/NULL,/*ioctl*/},{name##_BASE},}10存储器分类SRAM:synchronousrando