单片机
返回首页

STM8控制LCD12864液晶屏实验

2021-09-02 来源:eefocus

第一部分 并口传输显示中英文

主要是以下几个函数:

首先:写一个LCD_write函数来给LCD发送数据.根据时序图,发送数据是RW要置0,E要产生下降沿,RS置1为数据,RS置0为命令,由于是并口传输PSB置1.


其次:能够给LCD发命令后,我们就要使用LCD_init函数发送初始化命令。初始化命令至少包括:1、设置显示,2、功能设定,3、初始化清屏3个部分。


写命令时注意每个命令都有自己的运行时间,记得保证足够延时。


第三:写一个LCD_display函数可以分行分列显示内容。


void LCD_write(u8 data,u8 cmd_flag);

void LCD_init(void);

void LCD_display(u8 row,u8 col,u8 *string);


一、并口方式理论及资料

1.先上时序图:

这里要注意的是 PWeh 要大于450ns 以STM8S208MB内部16M RC振荡器计算,每次执行时间为: 1s/(16M/8分频) =500ns 所以必须延时保证E引脚上升区域大于450ns。


同理 tdsw也需要延时。


2.指令表

ST7920指令集分为2种,第一种:10种基础指令集RE=0,第二种:6种高级指令集RE=0

第一部分是显示中英文,所以只需用到基础指令集RE=0

3.引脚图和硬件电路

4.为什么每行可以写八个汉字或16个英文/数字?

因为每个汉字需要占2个字节。

此外还要留意,第一行和第三行的内存地址是连在一起的,不控制光标的话,写完第一行就会换行到第三行。(光标写完是自动加一的)

5.程序代码


//------------------------------header------------------------------------------

#include 'iostm8s208mb.h'

//------------------------------common datatype---------------------------------

typedef unsigned char uint8_t;

typedef unsigned short uint16_t;

typedef unsigned long uint32_t;

#define u8 uint8_t

#define u16 uint16_t

#define u32 uint32_t

//------------------------------macros------------------------------------------

#define LCDRS PF_ODR_ODR0

#define LCDRW PF_ODR_ODR3

#define LCDEN PF_ODR_ODR4

#define LCDPSB PF_ODR_ODR5

#define LCDDATA PB_ODR

//------------------------------function declare--------------------------------

void delay(u8 count);

void GPIO_init(void);

void LCD_write(u8 data,u8 cmd_flag);

void LCD_init(void);

void LCD_display(u8 row,u8 col,u8 *string);

//------------------------------global------------------------------------------

//------------------------------main--------------------------------------------

void main( void )

{

  GPIO_init();

  LCD_init();

  LCD_display(1,0,'熊爸的学习时间');

  LCD_display(2,0,'================');

  LCD_display(3,0,'使用LCD12864显示');

  LCD_display(4,0,'屏来并口显示数据');

  

}

//------------------------------functions---------------------------------------

void delay(u8 count)

{

  u8 i,j;

  while (count--)

  {

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

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

  }

}

void GPIO_init(void)

{

  //lcd DB0~DB7

  PB_DDR |=0XFF;

  PB_CR1 |=0XFF;

  PB_CR2 &=0X00;

  PB_ODR &=0X00;


  //LCD RS RW EN PSB

  PF_DDR |=0X39;

  PF_CR1 |=0X39;

  PF_CR2 &=0XC6;

  PF_ODR &=0XC6;


  LCDPSB=1;

  LCDRW=0;

}

void LCD_write(u8 data,u8 cmd_flag)

{

  LCDRS=cmd_flag;

  LCDEN=0;

  delay(1);

  LCDEN=1;

  LCDDATA=data;

  delay(1);       //delay保证E的周期

  LCDEN=0;

  delay(1);

}

void LCD_init(void)

{

  LCD_write(0X0C,0);

  delay(1);

  LCD_write(0X30,0);

  delay(1);

  LCD_write(0X01,0);

  delay(1);

}

void LCD_display(u8 row,u8 col,u8 *string)

{

  switch (row)

  {

    case 1:row=0X80;break;

    case 2:row=0X90;break;

    case 3:row=0X88;break;

    case 4:row=0X98;break;

    default:row=0X80;

  }

  LCD_write(row+col,0);

  while (*string != '')

  {

    LCD_write(*string,1);

    string++;

  }  

}


5.实验效果

第二部分 并行显示图片

1、指令集

使用绘图功能需要打开扩展指令集

2、绘画步骤

1.使用扩展指令集并关闭绘图显示功能 0X34
2.设置垂直地址
3.设置水平地址
4.写D15~D8位
5.写D7~D0位
6.打开绘图显示功能 0X36
7.返回基本指令集

垂直地址:表示方法 第几行+偏移量 例如: 0x80+j

水平地址:第一行0X80 第二行0X90 第三行0X88 第四行0X98

这部分处理函数如下:

void LCD_pic(u8 *pic)

{

  u8 i,j,k;

  LCD_write(0X34,0);delay(10);

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

  {

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

    {

      LCD_write(0X80+j,0);

      LCD_write(0X80+8*i,0);

      for ( k = 0; k <16; k++)

      {

        LCD_write(*pic++,1);

      }

    }

  }

  LCD_write(0X36,0);delay(10);

  LCD_write(0X30,0);delay(10);

}


3、再来看GDRAM

其实12864 只用了GDRAM的一半

Y坐标取值范围:0X80+0-31

X坐标取值范围:0X80或者0X88

//------------------------------header------------------------------------------

#include 'iostm8s208mb.h'

//------------------------------common datatype---------------------------------

typedef unsigned char uint8_t;

typedef unsigned short uint16_t;

typedef unsigned long uint32_t;

#define u8 uint8_t

#define u16 uint16_t

#define u32 uint32_t

//------------------------------macros------------------------------------------

#define LCDRS PF_ODR_ODR0

#define LCDRW PF_ODR_ODR3

#define LCDEN PF_ODR_ODR4

#define LCDPSB PF_ODR_ODR5

#define LCDDATA PB_ODR

//------------------------------function declare--------------------------------

void delay(u8 count);

void GPIO_init(void);

void LCD_write(u8 data,u8 cmd_flag);

void LCD_init(void);

void LCD_pic(u8 *pic);

//------------- -----------------global------------------------------------------

u8 dis[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x0F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x03,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x0F,0xFC,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x3F,0xF8,0x7F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0xFF,0xC3,0x0F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x01,0xFF,0xC7,0x8F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x07,0xFE,0x3F,0xF1,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x07,0xFC,0x3F,0xF0,0xFF,0x80,0x03,0x00,0x00,0x00,0x30,0x60,0x00,0x00,0x00,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00,0x7C,0x39,0xCE,0x6C,0xFC,0x0C,0xCC,0xCC,0x70,0x1C,

0x00,0x8F,0x03,0x03,0xE4,0x00,0xE0,0x0C,0x84,0x7C,0xCC,0xF8,0x80,0x04,0x3F,0xF8,

0x06,0x0F,0x00,0x03,0xE1,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x07,0x0F,0x00,0x03,0xC3,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x07,0xE3,0x00,0x03,0x1F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x07,0xF1,0x00,0x02,0x3F,0x81,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,

0x07,0xFE,0x00,0x01,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x07,0xFF,0x00,0x03,0xFF,0x81,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,

0x01,0xFF,0xC0,0x0F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x7F,0xE0,0x1F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x1F,0xF8,0x7F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x0F,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x01,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x07,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

//------------------------------main--------------------------------------------

void main( void )

{

  CLK_CKDIVR=0X00;

  delay(100);

  GPIO_init();

  LCD_init();

  LCD_pic(dis);

}

//------------------------------functions---------------------------------------

void delay(u8 count)

{

  u8 i,j;

  while (count--)

  {

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

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

  }

}

void GPIO_init(void)

{

  //lcd DB0~DB7

  PB_DDR |=0XFF;

  PB_CR1 |=0XFF;

  PB_CR2 &=0X00;

  PB_ODR &=0X00;


  //LCD RS RW EN PSB

  PF_DDR |=0X39;

  PF_CR1 |=0X39;

  PF_CR2 &=0XC6;

  PF_ODR &=0XC6;


  LCDPSB=1;

  LCDRW=0;

}

void LCD_write(u8 data,u8 cmd_flag)

{

  LCDRS=cmd_flag;

  LCDEN=0;

  delay(1);

  LCDDATA=data;

  LCDEN=1;

  delay(1);

  LCDEN=0; 

  delay(1);

}

void LCD_init(void)

{

  LCD_write(0X0C,0);

  delay(1);

  LCD_write(0X34,0);

  delay(1);

  LCD_write(0X01,0);

  delay(1);

}

void LCD_pic(u8 *pic)

{

  u8 i,j,k;

  LCD_write(0X34,0);delay(10);

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

  {

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

    {

      LCD_write(0X80+j,0);

      LCD_write(0X80+8*i,0);

      for ( k = 0; k <16; k++)

      {

        LCD_write(*pic++,1);

      }

    }

  }

  LCD_write(0X36,0);delay(10);

  LCD_write(0X30,0);delay(10);

}


实验效果:


这里说一下怎么得到DIS数组的

用PS制作一张128*64的BMP图片

然后将其导入 字模提取 软件中 用C51格式取模即可


第三部分 串口传输

串口传输非常省GPIO,可以做到用两个GPIO控制整块显示屏。非常给力!

选择串口通讯模式需要把PSB置0(或接GND)

此时 RS变为了片选端口 我们直接置1(或接VDD)

RW变成了SDIO 我们用它来发送数据 (接GPIO)

把EN变成了SCLK 我们用它来给通讯时钟(接GPIO)

1. 串口输出时序图

比如 我们发送一个命令 0X34到LCD,可以

11111 0 0 0 (命令控制字)0XF8

0011 0000 ( 0X34的高4位) 0X30

0100 0000( 0X34的低4位) 0X40


通过仔细观察时序图,我们发现:时钟为0时可以改变数据,时钟为1时采集。所以大体思路是在CLK=0时装载,在CLK=1时发射。

2. 需要写的函数

通过上面的分析总结出我们需要以下函数:

① 一个将命令/数据分解成3个字节并发送的处理函数

void LCD_write(u8 data,u8 cmd_flag)

{

  if(cmd_flag)

    LCD_send_byte(0XFA);

  else

    LCD_send_byte(0XF8);

  LCD_send_byte(data & 0XF0);

  LCD_send_byte((data<<4) & 0XF0);

}

②一个控制时钟引脚并将数据在SDIO口逐位发送的函数


LCD_send_byte(u8 byte)

{

  for (u8 i = 0; i < 8; i++)

  {

    LCDCLK=0;

    if ((byte<      LCDDIO=1;

    else

      LCDDIO=0;

    LCDCLK=1;

  }

}   

         

3.程序(用并行显示图片程序改的)


//------------------------------header------------------------------------------

#include 'iostm8s208mb.h'

//------------------------------common datatype---------------------------------

typedef unsigned char uint8_t;

typedef unsigned short uint16_t;

typedef unsigned long uint32_t;

#define u8 uint8_t

#define u16 uint16_t

#define u32 uint32_t

//------------------------------macros------------------------------------------

#define LCDCS PF_ODR_ODR0

#define LCDDIO PF_ODR_ODR3

#define LCDCLK PF_ODR_ODR4

#define LCDPSB PF_ODR_ODR5

//------------------------------function declare--------------------------------

void delay(u8 count);

void GPIO_init(void);

void LCD_write(u8 data,u8 cmd_flag);

void LCD_init(void);

void LCD_pic(u8 *pic);

void LCD_send_byte(u8 byte);

//------------- -----------------global------------------------------------------

u8 dis[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x0F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x03,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x0F,0xFC,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x3F,0xF8,0x7F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0xFF,0xC3,0x0F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x01,0xFF,0xC7,0x8F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x07,0xFE,0x3F,0xF1,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0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F0,0xF6,0x66,0xCC,0x0C,0xCC,0xCC,0x60,0x0C,

0x01,0x8F,0x0F,0xC3,0xE6,0x00,0x7C,0x39,0xCE,0x6C,0xFC,0x0C,0xCC,0xCC,0x70,0x1C,

0x00,0x8F,0x03,0x03,0xE4,0x00,0xE0,0x0C,0x84,0x7C,0xCC,0xF8,0x80,0x04,0x3F,0xF8,

0x06,0x0F,0x00,0x03,0xE1,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x07,0x0F,0x00,0x03,0xC3,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x07,0xE3,0x00,0x03,0x1F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x07,0xF1,0x00,0x02,0x3F,0x81,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,

0x07,0xFE,0x00,0x01,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x07,0xFF,0x00,0x03,0xFF,0x81,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,

0x01,0xFF,0xC0,0x0F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x7F,0xE0,0x1F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x1F,0xF8,0x7F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x0F,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x01,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x07,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

//------------------------------main--------------------------------------------

void main( void )

{

  CLK_CKDIVR=0X00;

  delay(100);

  GPIO_init();

  LCD_init();

  LCD_pic(dis);

}

//------------------------------functions---------------------------------------

void delay(u8 count)

{

  u8 i,j;

  while (count--)

  {

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

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

  }

}

void GPIO_init(void)

{

  //LCD CS DIO CLK PSB

  PF_DDR |=0X39;

  PF_CR1 |=0X39;

  PF_CR2 &=0XC6;

  PF_ODR &=0XC6;


  LCDPSB=0;

  LCDCS=1; 

}

void LCD_write(u8 data,u8 cmd_flag)

{

  if(cmd_flag)

    LCD_send_byte(0XFA);

  else

    LCD_send_byte(0XF8);

  LCD_send_byte(data & 0XF0);

  LCD_send_byte((data<<4) & 0XF0);

}

void LCD_init(void)

{

  LCD_write(0X0C,0);

  delay(1);

  LCD_write(0X34,0);

  delay(1);

  LCD_write(0X01,0);

  delay(1);

}

void LCD_pic(u8 *pic)

{

  u8 i,j,k;

  LCD_write(0X34,0);delay(10);

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

  {

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

    {

      LCD_write(0X80+j,0);

      LCD_write(0X80+8*i,0);

      for ( k = 0; k <16; k++)

      {

        LCD_write(*pic++,1);

      }

    }

  }

  LCD_write(0X36,0);delay(10);

  LCD_write(0X30,0);delay(10);

}

void LCD_send_byte(u8 byte)

{

  for (u8 i = 0; i < 8; i++)

  {

    LCDCLK=0;

    if ((byte<      LCDDIO=1;

    else

      LCDDIO=0;

    LCDCLK=1;

  }

}


进入单片机查看更多内容>>
相关视频
  • RISC-V嵌入式系统开发

  • SOC系统级芯片设计实验

  • 云龙51单片机实训视频教程(王云,字幕版)

  • 2022 Digi-Key KOL 系列: 你见过1GHz主频的单片机吗?Teensy 4.1开发板介绍

  • TI 新一代 C2000™ 微控制器:全方位助力伺服及马达驱动应用

  • MSP430电容触摸技术 - 防水Demo演示

精选电路图
  • 家用电源无载自动断电装置的设计与制作

  • 用数字电路CD4069制作的万能遥控轻触开关

  • 使用ESP8266从NTP服务器获取时间并在OLED显示器上显示

  • 开关电源的基本组成及工作原理

  • 用NE555制作定时器

  • 带有短路保护系统的5V直流稳压电源电路图

    相关电子头条文章