lgeorge123 发表于 2011-2-23 17:16:10

fpga 推不到3.5" LCD

我用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 longk;
   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);
}

Jigsaw 发表于 2011-2-23 17:47:33

CPLD的IO比FPGA更快都有很多人成功驱动过了,应该不会是CPU clock 的问题
页: [1]
查看完整版本: fpga 推不到3.5" LCD