搜索
bottom↓
回复: 1

fpga 推不到3.5" LCD

[复制链接]

出0入0汤圆

发表于 2011-2-23 17:16:10 | 显示全部楼层 |阅读模式
我用EP2C8Q208C8 , Quartus 10.1 sp1 (晶振50M) 入CPU 是100MHZ 和NIOS II 10.1 SP1推3.5 " LCD ILI9481 480X320 ,想出全屏綠色可是不成功  以下是我的程序 , 請各位看看有沒有問題 .LCD 是沒有問題 .是不是CPU clock 太快


#include "sys/alt_stdio.h"
#include "system.h"
#include "altera_avalon_pio_regs.h"
#include "alt_types.h"

#include <unistd.h>
void wr_comm(unsigned short index);
void wr_dat(unsigned short dat);
void lcd_int(void);
void wr_com(unsigned short i,unsigned short j);
void windows_FILL();
void delay_ms(unsigned short i);


void wr_comm(unsigned short index)
{  
   IOWR_ALTERA_AVALON_PIO_DATA(PIO_RS_BASE ,0);
   IOWR_ALTERA_AVALON_PIO_DATA(PIO_DATA_BASE,index);
   IOWR_ALTERA_AVALON_PIO_DATA(PIO_WR_BASE ,0);
   IOWR_ALTERA_AVALON_PIO_DATA(PIO_WR_BASE ,1);
}


void wr_dat(unsigned short dat)
{  
  IOWR_ALTERA_AVALON_PIO_DATA(PIO_RS_BASE ,1);
  IOWR_ALTERA_AVALON_PIO_DATA(PIO_DATA_BASE,dat);
  IOWR_ALTERA_AVALON_PIO_DATA(PIO_WR_BASE ,0);
   IOWR_ALTERA_AVALON_PIO_DATA(PIO_WR_BASE ,1);
}

void lcd_int(void)
{
    IOWR_ALTERA_AVALON_PIO_DATA(PIO_LCD_RESET_BASE ,1); //output_high(pin_a5);
    delay_ms(100);   
    IOWR_ALTERA_AVALON_PIO_DATA(PIO_LCD_RESET_BASE ,0); //output_low(pin_a5);
    delay_ms(100);
    IOWR_ALTERA_AVALON_PIO_DATA(PIO_LCD_RESET_BASE ,1);
    delay_ms(100);
     IOWR_ALTERA_AVALON_PIO_DATA(PIO_CS_BASE ,0);
    wr_comm(0x0011);
  delay_ms(500);
  wr_comm(0x0013);
  
  wr_comm(0x00D0);
  wr_dat(0x0007);
  wr_dat(0x0040); //41   
  wr_dat(0x001c);//1e

   
  wr_comm(0x00D1);
  wr_dat(0x0000);
  wr_dat(0x0018);
  wr_dat(0x001d);
  
  wr_comm(0x00D2);
  wr_dat(0x0001);
  wr_dat(0x0011);//11

  wr_comm(0x00C0);
  wr_dat(0x0000);
  wr_dat(0x003B);
  wr_dat(0x0000);
  wr_dat(0x0002);
  wr_dat(0x0011);

  wr_comm(0x00C1);
  wr_dat(0x0010);
  wr_dat(0x000B);
  wr_dat(0x0088);
  wr_comm(0x000b);
  wr_dat(0x0008);
  wr_comm(0x00C5);
  wr_dat(0x0001);
   
  wr_comm(0x00C8);
  wr_dat(0x0000);
  wr_dat(0x0030); //30
  wr_dat(0x0036);
  wr_dat(0x0045);
  wr_dat(0x0004);
  wr_dat(0x0016);
  wr_dat(0x0037);
  wr_dat(0x0075);
  wr_dat(0x0077);
  wr_dat(0x0054);
  wr_dat(0x000f);
  wr_dat(0x0000);
  
  wr_comm(0x00E4);
  wr_dat(0x00A0);
  
    wr_comm(0x00F0);
  wr_dat(0x0001);
  
  wr_comm(0x00F3);
  wr_dat(0x0040);
  wr_dat(0x000A);
  
  wr_comm(0x00F7);
  wr_dat(0x0080);
  
  wr_comm(0x0036);
  wr_dat(0x0002b);
  
  wr_comm(0x003A);
  wr_dat(0x0055);
  
   wr_comm(0x002A);
   wr_dat(0x0000);
    wr_dat(0x0000);
    wr_dat(0x0001);
   wr_dat(0x00dF);

    wr_comm(0x002B);
    wr_dat(0x0000);
    wr_dat(0x0000);
    wr_dat(0x0001);
   wr_dat(0x003f);
  
delay_ms(600);
  wr_comm(0x0029);
  wr_comm(0x002C);
   IOWR_ALTERA_AVALON_PIO_DATA(PIO_CS_BASE ,1);
}
void windows_FILL( )
{
   unsigned short i,n;
   unsigned long  k;
     k = 0;
      IOWR_ALTERA_AVALON_PIO_DATA(PIO_CS_BASE ,0);
     wr_comm(0x002A);
wr_dat(0x0000);
wr_dat(0x0000);
wr_dat(0x0001);
wr_dat(0x00df);
wr_comm(0x002B);
wr_dat(0x0000);
wr_dat(0x0000);
wr_dat(0x0001);
wr_dat(0x003f);
   wr_comm(0x002c);   
   for(n=0;n<480;n++)   
     for(i=0;i<320;i++)
       wr_dat(0x2fe0);  
        IOWR_ALTERA_AVALON_PIO_DATA(PIO_CS_BASE ,1);     
}

void delay_ms(unsigned short i)
{
  unsigned short j,k;
  for(j=0;j<i;j++)
  {
   for(k=0;k<1000;k++);
  }
}

int main(void)
{  
    lcd_int();     
       windows_FILL();   
while(1);
}

阿莫论坛20周年了!感谢大家的支持与爱护!!

知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)

出0入0汤圆

发表于 2011-2-23 17:47:33 | 显示全部楼层
CPLD的IO比FPGA更快都有很多人成功驱动过了,应该不会是CPU clock 的问题
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-7-24 15:16

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表