打印

最近使用LPC1343驱动OCMJ8X15B,就是不显示???

[复制链接]
2061|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
604836807|  楼主 | 2011-7-27 14:47 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
/****************************************************************************
*   $Id:: gpiotest.c 7177 2011-04-26 23:08:15Z usb00423                    $
*   Project: NXP LPC13xx GPIO example
*
*   Description:
*     This file contains GPIO test modules, main entry, to test GPIO APIs.
*
****************************************************************************
* Software that is described herein is for illustrative purposes only
* which provides customers with programming information regarding the
* products. This software is supplied "AS IS" without any warranties.
* NXP Semiconductors assumes no responsibility or liability for the
* use of the software, conveys no license or title under any patent,
* copyright, or mask work right to the product. NXP Semiconductors
* reserves the right to make changes in the software without
* notification. NXP Semiconductors also make no representation or
* warranty that such application will be suitable for the specified
* use without further testing or modification.
****************************************************************************/
#include "LPC13xx.h"
/* LPC13xx Peripheral Registers */
#include "gpio.h"





#define BUS_NO 0
//定义总线起始的IO口,例如P2.0
#define LCM_BUS_PORT 2

#define Data_Start()
(LPC_GPIO2->DATA &= ~(0xFF << BUS_NO))
//总线位全部拉低,准备数据
//#define Data_Send(dat)
(LPC_GPIO2->DATA=LPC_GPIO1->DATA & (~(0xFF << BUS_NO))|(dat<<BUS_NO))  //发送数据
#define Data_Send(dat)
(LPC_GPIO2->DATA=dat)  //发送数据



#define LCM_BUSY 0
//定义BUSY

#define BUSY_1
LPC_GPIO3->DATA&(1<<LCM_BUSY)
//忙查询


#define LCM_REQ 1
//定义REQ
#define SREQ()
LPC_GPIO3->DATA|=1<<LCM_REQ
   //请求信号,高电平有效
#define CREQ()
LPC_GPIO3->DATA&=~(1<<LCM_REQ)

#define LCM_RES 2
//定义RES
#define SRES()
LPC_GPIO3->DATA|=1<<LCM_RES
   //复位信号,低电平有效
#define CRES()
LPC_GPIO3->DATA&=~(1<<LCM_RES)


void delay(void)
{

uint32_t i;

for(i=0;i<1000;i++);
}

void LCM_Send(uint32_t dat)
{



Data_Start();
   //准备数据

while(BUSY_1==1);
   //忙检查

delay();
   //???

Data_Send(dat);
   //发送数据

delay();

SREQ();
   //请求信号REQ

delay();

CREQ();
//撤销请求

while(BUSY_1==0);
   //确认

delay();

  
}

void LCM_Command(uint32_t comm,uint32_t addr_x,uint32_t addr_y)
{

LCM_Send(comm);
   //发送命令



LCM_Send(addr_x);
   //发送坐标

LCM_Send(addr_y);

}

void LCM_Reset(void)
{

CRES();
//复位
(低电平有效)

delay();
//???????

SRES();

}

void LCM_ClrScr(void)
//清屏
{

LCM_Send(0xf4);
}
void LCM_UpScr(void)
//上移
{

LCM_Send(0xf5);
}
void LCM_DownScr(void)
//下移
{

LCM_Send(0xf6);
}
void LCM_LeftScr(void)
//
左移
{

LCM_Send(0xf7);
}
void LCM_RightScr(void)
//
右移
{

LCM_Send(0xf8);
}
void LCM_White(void)
//反白
{

LCM_Send(0xfa);
}

void LCM_ShowTrad(uint8_t trad)
  //显示光标
{

LCM_Send(0xFB);


LCM_Send(trad);
// 0x00:关闭   0x07:光标为八点长度   0x0f:光标为16点长度
}

void LCM_MoveTradSpeed(uint8_t LCM_Speed)
  //显示光标
{

LCM_Send(0xFC);


LCM_Send(LCM_Speed);
// 0x00: 一点  0x01: 两点    0x07:八点  0x0f:16点
}

void show(uint8_t x,uint8_t y,char *buf)
   //显示
{

while(*buf)

{

LCM_Command(0xf9,x+4,y*8);

LCM_Send(*(buf++));

x++;

}

}

void Disp_eng(uint32_t x,uint32_t m)   //显示数字
{


//
GPIOSetDir( PORT1, 8, 1 );
//
GPIOSetValue( PORT1, 8, 1 );
//
GPIOIntEnable( PORT1, 8 );


LCM_Command(0xf9,x,16);

LCM_Send(m);
}

void  Disp_eng1(uint8_t const *eng)
//显示8*16字符
{

uint32_t i,j;

for(j=0;j<4;j++)

{

for(i=4;i<20;i++)

{


LCM_Command(0xf9,i,j*16);

LCM_Send(eng[j*16+i-4]);

}

}
}


void Disp_chn1(uint8_t const *chn,uint8_t num,uint8_t line,uint8_t row)
   //显示汉字
{

uint8_t i;

for(i=3;i<num+3;i++)

{

LCM_Command(0xf0,i-4+row,line-1);

LCM_Send(chn[(i-3)*2]-0xa0);

LCM_Send(chn[(i-3)*2+1]-0xa0);

}


}

void GUI_Point(uint8_t x,uint8_t y)
// x: 0~239
y: 0~127
画点
{

LCM_Command(0xf2,x,y);
}

void GUI_HLine(uint8_t xx,uint8_t yy,uint8_t x1)
  //画线 xx起始点,x1终点
{

uint8_t bak;


if(xx>x1)//排序,方便画图

{

   bak=x1;

   x1=xx;

   xx=bak;

}


do

{

   GUI_Point(xx,yy);

   xx++;

}while(x1>=xx);
}



void LCM_DispInit(void)
{

LPC_GPIO3->DIR |= (1<<LCM_REQ)|(1<<LCM_RES);
//
LPC_GPIO3->DIR |= (1<<LCM_BUSY)|(1<<LCM_REQ)|(1<<LCM_RES);
    LPC_GPIO2->DIR |= (0xff<<BUS_NO);

LPC_GPIO3->DIR &= ~(1<<LCM_BUSY);

LCM_Reset();//复位一下

LCM_ClrScr();
    LCM_ClrScr();
}


/*****************************************************************************
**   Main Function  main()
******************************************************************************/
int main (void)
{

SystemInit();

GPIOInit();

LCM_DispInit();



LCM_ClrScr();


SREQ();

//
LCM_White();
Disp_eng(0,36);
//
GUI_HLine(0,16,100);
// LCM_ShowTrad(0x0f);






   

GPIOSetDir( PORT1, 8, 1 );
  



while( 1 )

{

int i;



GPIOSetValue( PORT1, 8, 1 );


for(i=0;i<1000;i++)

{

delay();

}

  
GPIOSetValue( PORT1, 8, 0 );


for(i=0;i<1000;i++)

{


delay();


}

}
}

/*********************************************************************************
**                            End Of File
*********************************************************************************/

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

6

帖子

1

粉丝