搜索
bottom↓
回复: 3

msp430液晶驱动的问题

[复制链接]

出0入0汤圆

发表于 2011-1-25 20:00:44 | 显示全部楼层 |阅读模式
有那位大哥使用msp430驱动过400*240的TFT液晶屏,驱动芯片是ILI9327,小弟不胜感激

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

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

出0入0汤圆

 楼主| 发表于 2011-1-30 12:18:16 | 显示全部楼层
#define CPU_F ((double)8000000)
#define delay_us(x) __delay_cycles((long)(CPU_F*(double)x/1000000.0))
#define delay_ms(x) __delay_cycles((long)(CPU_F*(double)x/1000.0))
#include "msp430x16x.h"

void lcd_int(void);
void wr_com(unsigned int,unsigned int);
void wr_dat(unsigned int);
void dis_color2(unsigned int);


void main( void )
{
  // Stop watchdog timer to prevent time out reset
  WDTCTL = WDTPW + WDTHOLD;
  int i;
  BCSCTL1 &= ~XT2OFF;                       // XT2= HF XTAL
  do
  {
    IFG1 &= ~OFIFG;                           // Clear OSCFault flag
    for (i = 0xFF; i > 0; i--);               // Time for flag to set
  }
  while ((IFG1 & OFIFG));                   // OSCFault flag still set?
  BCSCTL2 |= SELM_2;                        // MCLK= XT2 (safe)
  //---PortTFT-----//
  P1DIR = 0xFF;
  P2DIR = 0xFF;
  P3DIR = 0xFF;
  P1OUT = 0x00;
  P2OUT = 0x00;
  P3OUT = 0xFF;
  //---ResetTFT----//
   P3OUT |= 0x10;
   delay_ms(5);
   P3OUT &= 0xEF;
   delay_ms(10);
   P3OUT |= 0x10;
   delay_ms(100);  
//---InitializeTFT----//
   lcd_int();
   delay_ms(500);
  dis_color2(0xffff);
while(1);
}

出0入0汤圆

 楼主| 发表于 2011-1-30 12:19:49 | 显示全部楼层
/***********************************************************
Instruction : Write Command to ILI9327.Port 1 set Low 8 bits
***********************************************************/
void wr_comm(unsigned int index)
{  

   P3OUT &= 0xFE;
   P3OUT &= 0xF7;
   P1OUT = index;
   P2OUT = index>>8;
   delay_ms(1);
   P3OUT &= 0xFD;
   delay_ms(1);
   P3OUT |= 0x02;
   delay_ms(1);
   P3OUT |= 0x08;
}
/***********************************************************
Instruction : Write Data to ILI9327.Port 2 set High 8 bits
***********************************************************/
void wr_dat(unsigned int dat)
{  

   P3OUT |= 0x01;
   P3OUT &= 0xF7;
   P1OUT = dat;
   P2OUT = dat>>8;
   delay_ms(1);
   P3OUT &= 0xFD;
   delay_ms(1);
   P3OUT |= 0x02;
   delay_ms(1);
   P3OUT |= 0x08;
}
/***********************************************************
Instruction : Lcd Initial with Rest in more than 200ms
              Exit sleep
              Set Gamma
***********************************************************/
void lcd_int(void)
{
//************* Reset LCD Driver ****************//

  P3OUT |= 0x10;
  delay_ms(5); // Delay 1ms
  P3OUT &= 0xEF;
  delay_ms(20); // Delay 20ms // This delay time is necessary
  P3OUT |= 0x10;
  delay_ms(200); // Delay 200 ms
  wr_comm(0xE9);
  wr_dat (0x20);
  wr_comm(0x11); //Exit Sleep
  delay_ms(100);
  wr_comm(0xD1);
  wr_dat (0x00);
  wr_dat (0x71);
  wr_dat (0x19);
  wr_comm(0xD0);
  wr_dat (0x07);
  wr_dat (0x01);
  wr_dat (0x08);
  wr_comm(0x36);
  wr_dat (0x48);
  wr_comm(0x3A);
  wr_dat (0x05);
  wr_comm(0xC1);
  wr_dat (0x10);
  wr_dat (0x10);
  wr_dat (0x02);
  wr_dat (0x02);
  wr_comm(0xC0); //Set Default Gamma
  wr_dat (0x00);
  wr_dat (0x35);
  wr_dat (0x00);
  wr_dat (0x00);
  wr_dat (0x01);
  wr_dat (0x02);
  wr_comm(0xC5); //Set frame rate
  wr_dat (0x04);
  wr_comm(0xD2); //power setting
  wr_dat (0x01);
  wr_dat (0x44);
  wr_comm(0xC8); //Set Gamma
  wr_dat (0x04);
  wr_dat (0x67);
  wr_dat (0x35);
  wr_dat (0x04);
  wr_dat (0x08);
  wr_dat (0x06);
  wr_dat (0x24);
  wr_dat (0x01);
  wr_dat (0x37);
  wr_dat (0x40);
  wr_dat (0x03);
  wr_dat (0x10);
  wr_dat (0x08);
  wr_dat (0x80);
  wr_dat (0x00);
  wr_comm(0x2A);
  wr_dat (0x00);
  wr_dat (0x00);
  wr_dat (0x00);
  wr_dat (0xeF);
  wr_comm(0x2B);
  wr_dat (0x00);
  wr_dat (0x00);
  wr_dat (0x01);
  wr_dat (0x8F);
  wr_comm(0x29); //display on      
  wr_comm(0x2C); //display on   
}

出0入0汤圆

 楼主| 发表于 2011-1-30 12:20:13 | 显示全部楼层
void dis_color2(unsigned int j)                  
{       
   unsigned int i,m;
   wr_comm(0x002c);
   P3OUT |= 0x01;
   P3OUT &= 0xF7;  
   for(i=0;i<400;i++)
    for(m=0;m<240;m++)
      {
        P1OUT = j;
        P2OUT = j>>8;  
        P3OUT &= 0xFD;
        P3OUT |= 0x02;
      }
   P3OUT |= 0x08;      
}



没办法,还得自己给出来啊,有兴趣的通知可以看看
编译环境为:IAR EWB 5.21B
连接方式:MSP430F169
  P1口:DB0-DB7
  P2口:DB8-DB15
  P3口:依次由P3.0-P3.5为:RS、WR、RD、CS、REST
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-7-28 15:11

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

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