液晶模块


在淘宝购买到 液晶12864COG 液晶模块串口/并口ST7565R带背3.3v 12864-14显示屏 用于之后人工神经网络模式识别图片采集使用。

▲ 液晶外形

▲ 液晶外形

1.接口定义

▲ 外部引脚定义

▲ 外部引脚定义

▲ 不同命令模式对应的引线

▲ 不同命令模式对应的引线

▲ 模块后面设置接口串并对应的电阻

▲ 模块后面设置接口串并对应的电阻

▲ ST7565R串口与并口对应情况

▲ ST7565R串口与并口对应情况

▲ 在RESET管脚增加一个10kΩ的上拉电阻

▲ 在RESET管脚增加一个10kΩ的上拉电阻

2.驱动器ST7565R

可以参照网络上对应的 ST7565R开发程序

 

02实验电路板1


1.电路板设计制作

使用ADuC845-3作为实验控制器。基于ADuC845来测试ST7565R液晶显示器的功能。

▲ 实验电路SCH

▲ 实验电路SCH

※ 错误: 在开始的时候将CS,ID设置错误了。将其颠倒过来即可。

▲ 实验电路板PCB

▲ 实验电路板PCB

2.初步测试2

根据 创界uVision下的ADuC845的工程文件 中描述的方式对于开发板建立测试工程文件并进行程序下载。

C51\ADuC845\Test\2020\TestLCD\TestLCD.uvproj

3.制作LCD外部接口

使用串口对外接口的定义:

PIN14PIN12PIN11PIN10PIN9PIN8PIN7
DICSLEDAVSSVDDSISCK

▲ LCD对外引脚

▲ LCD对外引脚

▲ 连线的关系

▲ 连线的关系

▲ LCD外部引脚的设计

▲ LCD外部引脚的设计

★ 注意:
使用电阻将LCD的reset管脚连接到VCC.这个电阻可以使用R14处焊接10kΩ电阻。

▲ 使用10k欧姆将RESET连接到VCC

▲ 使用10k欧姆将RESET连接到VCC

 

03液晶底层程序


1.底层协议

根据 ST7565R数据手册 描述,ST7565R的SPI接口协议协议为:

▲ ST7565 SPI接口协议

▲ ST7565 SPI接口协议

▲ ST7565所有命令

▲ ST7565所有命令

2.主要子程序

(1) 延迟子程序
  • ST7565Nop(unsigned int nCommand);
nCount = 446;
while(1) {
    ST7565Nop(nCount);
    ST7565_SCK = 1;
    ST7565Nop(nCount);
    ST7565_SCK = 0;
    
}
Command255010025050010002000
Frequency8642.64390.92213.2889.7445.5222.9111.5

▲ 设置Count与延迟之间的关系

▲ 设置Count与延迟之间的关系

使用最后一个数值求得Count与延迟之间的关系:
R c / t = D e l a y C o u n t = 2.2422    u s / c o u n t R_{c/t} = {{Delay} \over {Count}} = 2.2422\,\,us/count Rc/t=CountDelay=2.2422us/count

所以,延迟1ms(1000us)需要设置Count为:
C o u n t = 1000 R c / d = 1000 2.2422 = 445.99 Count = {{1000} \over {R_{c/d} }} = {{1000} \over {2.2422}} = 445.99 Count=Rc/d1000=2.24221000=445.99
实际测量得到的延迟为:1001.34us。

(2) 其它子程序
/*
**==============================================================================
** ST7565.H:            -- by Dr. ZhuoQing, 2020-10-31
**
**  Description:
**
**==============================================================================
*/
#ifndef __ST7565__
#define __ST7565__
//------------------------------------------------------------------------------
#ifdef ST7565_GLOBALS
   #define ST7565_EXT
#else
   #define ST7565_EXT extern
#endif // ST7565_GLOBALS
//------------------------------------------------------------------------------
//==============================================================================
sbit    ST7565_SCK = P3^4;
sbit    ST7565_SI  = P3^5;
sbit    ST7565_CS  = P3^6;
sbit    ST7565_DI  = P3^7;
 
//------------------------------------------------------------------------------
void ST7565Init(void);
void ST7565Nop(unsigned int nTime);         // nTime:-->Delay(us) = 2.2422 us/counc
                                            // For 1000us: nTIme = 446
#define ST7565_DELAY_MS             ST7565Nop(446)
void ST7565DelayMS(unsigned int nms);

void ST7565OutByte(unsigned char ucByte);

void ST7565Command(unsigned char ucByte);
void ST7565Data(unsigned char ucByte);

//------------------------------------------------------------------------------
#define ST7565_CMD_DISPLAY_ON       0xaf
#define ST7565_CMD_DISPLAY_OFF      0xae
#define ST7565_DISPLAY_ON           ST7565Command(ST7565_CMD_DISPLAY_ON)
#define ST7565_DISPLAY_OFF          ST7565Command(ST7565_CMD_DISPLAY_OFF)

void ST7565StartLine(unsigned char ucLines);
void ST7565SetPage(unsigned char ucPages);
void ST7565SetColumn(unsigned char ucCols);
void ST7565WriteDataDim(unsigned char *pucByte, int nNumber);

#define ST7565_SDD_NORMAL           ST7565Command(0xa0)
#define ST7565_SDD_REVERSE          ST7565Command(0xa1)
#define ST7565_DISPLAY_NORMAL       ST7565Command(0xa6)
#define ST7565_DISPLAY_REVERSE      ST7565Command(0xa7)
#define ST7565_DISPLAY_ALL_OFF      ST7565Command(0xa4)
#define ST7565_DISPLAY_ALL_ON       ST7565Command(0xa5)
#define ST7565_BIAS_1               ST7565Command(0xa2)
#define ST7565_BIAS_2               ST7565Command(0xa3)
#define ST7565_READWRITE_MODE       ST7565Command(0xe0)
#define ST7565_END                  ST7565Command(0xee)
#define ST7565_RESET                ST7565Command(0xe2)
#define ST7565_NOP                  ST7565Command(0xe3)

void ST7565Clear(unsigned char ucData1);

//------------------------------------------------------------------------------
void ST7565GotoXY(unsigned char ucX, unsigned char ucY);
void ST7565SetPoint(unsigned char ucX, unsigned ucY);

//------------------------------------------------------------------------------
extern const unsigned char code F6x8[][6];
extern const unsigned char code F8X16[];

void ST7565OutChar8X16(unsigned char ucX, unsigned char ucY, unsigned char ucChar);
void ST7565OutChar6X8(unsigned char ucX, unsigned char ucY, unsigned char ucChar);

void ST7565OutString8X16(unsigned char ucX, unsigned char ucY, char * p);
//void ST7565OutString8X16C(unsigned char ucX, unsigned char ucY, const char * p);
void ST7565OutString6X8(unsigned char ucX, unsigned char ucY, char * p);
//void ST7565OutString6X8C(unsigned char ucX, unsigned char ucY, const char * p);

#define ST7565_Print(x, y, p) ST7565OutString8X16(x, y, p)
#define ST7565_print(x, y, p) ST7565OutString6X8(x, y, p)

//==============================================================================
//             END OF THE FILE : ST7565.H
//------------------------------------------------------------------------------
#endif // __ST7565__
/*
**==============================================================================
** ST7565.C:             -- by Dr. ZhuoQing, 2020-10-31
**
**==============================================================================
*/
#include <ADUC845.h>
#include <stdio.h>
#include <intrins.h>
#include "uc845.h"

//------------------------------------------------------------------------------
#define ST7565_GLOBALS        1              // Define the global variables
#include "ST7565.H"

//------------------------------------------------------------------------------
void ST7565Init(void) {
    ST7565_SCK = 1;
    ST7565_SI  = 1;
    ST7565_DI  = 1;
    ST7565_CS  = 1;    
    
    //--------------------------------------------------------------------------
    ST7565DelayMS(10);
    
    ST7565Command(0xa2);                    // Set Bias:0xa2     
    ST7565Command(0xc8);                    // Command Direction Select:
                                            //  bit3=1:Reverse; bit3=0:normal                                                
    ST7565Command(0x2f);                    // Power control set
    ST7565Command(0x24);                    // Set ra/rb 0x25
    ST7565Command(0x81);                    // Set Contrast
    ST7565Command(0x27);                    // Set ra/rb 
    ST7565Command(0xaf);                    // Display ON
    ST7565Clear(0);
}

//------------------------------------------------------------------------------
void ST7565Nop(unsigned int nTime) {
    while(nTime --) {
        _nop_();
    }

}

void ST7565DelayMS(unsigned int nms) {
    unsigned int i;
    for(i = 0; i < nms; i ++)
        ST7565_DELAY_MS;
}

//------------------------------------------------------------------------------
#define ST7565_CLK_NOP      0
//------------------------------------------------------------------------------
void ST7565OutByte(unsigned char ucByte) {
    unsigned char ucMask, i;
    ucMask = 0x80;
    
    ST7565_SCK = 1;
    for(i = 0; i < 8; i ++) {
        ST7565_SCK = 0;
        
        if(ucByte & ucMask) ST7565_SI = 1;
        else ST7565_SI = 0;
        
        ST7565Nop(ST7565_CLK_NOP);
        
        ST7565_SCK = 1;
        ST7565Nop(ST7565_CLK_NOP);
        
        ucMask >>= 1;        
    }
}

//------------------------------------------------------------------------------
void ST7565Command(unsigned char ucByte) {
    ST7565_CS = 0;
    ST7565_DI = 0;    
    ST7565OutByte(ucByte);
    ST7565_CS = 1;
}

//------------------------------------------------------------------------------
void ST7565Data(unsigned char ucByte) {
    ST7565_CS = 0;
    ST7565_DI = 1;    
    ST7565OutByte(ucByte);
    ST7565_CS = 1;
}

void ST7565StartLine(unsigned char ucLines) {
    unsigned char ucCommand;
    ucCommand = ucLines & 0x3f;
    ucCommand |= 0x40;
    ST7565Command(ucCommand);
}

void ST7565SetPage(unsigned char ucPages) {
    unsigned char ucCommand;
    ucCommand = ucPages & 0xf;
    ucCommand |= 0xb0;
    ST7565Command(ucCommand);
    
}

void ST7565SetColumn(unsigned char ucCols) {
    unsigned char ucCommand;
    ucCommand = ucCols >> 4;
    ucCommand |= 0x10;
    ST7565Command(ucCommand);
    ucCommand = ucCols & 0xf;
    ST7565Command(ucCommand);
    
}

//------------------------------------------------------------------------------
void ST7565WriteDataDim(unsigned char *pucByte, int nNumber) {
    unsigned int i;
    ST7565_DI = 1;
    ST7565_CS = 0;
    for(i = 0; i < nNumber; i ++)
        ST7565OutByte(*(pucByte ++));
        
    ST7565_CS = 1;
}

//------------------------------------------------------------------------------
void ST7565Clear(unsigned char ucData1) {
    unsigned char i, j, m;
    m = 0xb0;                               // Page Address Set
    for(i = 0; i < 8; i ++) {
        ST7565Command(m);
        ST7565Command(0x10);                // Set Column address
        ST7565Command(0x00);
        for(j = 0; j < 192; j ++) {
            ST7565Data(ucData1);
        }
        m ++;
    }
}

//------------------------------------------------------------------------------
void ST7565GotoXY(unsigned char ucX, unsigned char ucY) {
    ST7565SetPage(ucY);
    ST7565SetColumn(ucX);
}

void ST7565SetPoint(unsigned char ucX, unsigned ucY) {
    unsigned char ucY8;
    unsigned char ucByte;
    ucY8 = ucY >> 3;
    ucY = ucY & 0x7;
    ucByte = 1 << ucY;

    ST7565SetPage(ucY8);
    ST7565SetColumn(ucX);
    ST7565Data(ucByte);
    
}

//------------------------------------------------------------------------------
const unsigned char code F6x8[][6] =
{
    { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // sp
    { 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 },   // !
    { 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 },   // "
    { 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 },   // #
    { 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 },   // $
    { 0x00, 0x62, 0x64, 0x08, 0x13, 0x23 },   // %
    { 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 },   // &
    { 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 },   // '
    { 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 },   // (
    { 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 },   // )
    { 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 },   // *
    { 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 },   // +
    { 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 },   // ,
    { 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 },   // -
    { 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 },   // .
    { 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 },   // /
    { 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E },   // 0
    { 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 },   // 1
    { 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 },   // 2
    { 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 },   // 3
    { 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 },   // 4
    { 0x00, 0x27, 0x45, 0x45, 0x45, 0x39 },   // 5
    { 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 },   // 6
    { 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 },   // 7
    { 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 },   // 8
    { 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E },   // 9
    { 0x00, 0x00, 0x36, 0x36, 0x00, 0x00 },   // :
    { 0x00, 0x00, 0x56, 0x36, 0x00, 0x00 },   // ;
    { 0x00, 0x08, 0x14, 0x22, 0x41, 0x00 },   // <
    { 0x00, 0x14, 0x14, 0x14, 0x14, 0x14 },   // =
    { 0x00, 0x00, 0x41, 0x22, 0x14, 0x08 },   // >
    { 0x00, 0x02, 0x01, 0x51, 0x09, 0x06 },   // ?
    { 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E },   // @
    { 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C },   // A
    { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36 },   // B
    { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 },   // C
    { 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C },   // D
    { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41 },   // E
    { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01 },   // F
    { 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A },   // G
    { 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F },   // H
    { 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00 },   // I
    { 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01 },   // J
    { 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 },   // K
    { 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40 },   // L
    { 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F },   // M
    { 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F },   // N
    { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E },   // O
    { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06 },   // P
    { 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E },   // Q
    { 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46 },   // R
    { 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 },   // S
    { 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01 },   // T
    { 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F },   // U
    { 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F },   // V
    { 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F },   // W
    { 0x00, 0x63, 0x14, 0x08, 0x14, 0x63 },   // X
    { 0x00, 0x07, 0x08, 0x70, 0x08, 0x07 },   // Y
    { 0x00, 0x61, 0x51, 0x49, 0x45, 0x43 },   // Z
    { 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00 },   // [
    { 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55 },   // 55
    { 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00 },   // ]
    { 0x00, 0x04, 0x02, 0x01, 0x02, 0x04 },   // ^
    { 0x00, 0x40, 0x40, 0x40, 0x40, 0x40 },   // _
    { 0x00, 0x00, 0x01, 0x02, 0x04, 0x00 },   // '
    { 0x00, 0x20, 0x54, 0x54, 0x54, 0x78 },   // a
    { 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38 },   // b
    { 0x00, 0x38, 0x44, 0x44, 0x44, 0x20 },   // c
    { 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F },   // d
    { 0x00, 0x38, 0x54, 0x54, 0x54, 0x18 },   // e
    { 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02 },   // f
    { 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C },   // g
    { 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78 },   // h
    { 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00 },   // i
    { 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00 },   // j
    { 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00 },   // k
    { 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00 },   // l
    { 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78 },   // m
    { 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78 },   // n
    { 0x00, 0x38, 0x44, 0x44, 0x44, 0x38 },   // o
    { 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18 },   // p
    { 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC },   // q
    { 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08 },   // r
    { 0x00, 0x48, 0x54, 0x54, 0x54, 0x20 },   // s
    { 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20 },   // t
    { 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C },   // u
    { 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C },   // v
    { 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C },   // w
    { 0x00, 0x44, 0x28, 0x10, 0x28, 0x44 },   // x
    { 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C },   // y
    { 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44 },   // z
    { 0x14, 0x14, 0x14, 0x14, 0x14, 0x14 }    // horiz lines
};

//======================================================
// 128X64I 
// !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
//======================================================
const unsigned char code F8X16[]=
{
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0
  0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//!1
  0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//"2
  0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//#3
  0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$4
  0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//%5
  0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//&6
  0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//'7
  0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//(8
  0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//)9
  0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//*10
  0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+11
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//,12
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//-13
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//.14
  0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,///15
  0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//016
  0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//117
  0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//218
  0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//319
  0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//420
  0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//521
  0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//622
  0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//723
  0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//824
  0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//925
  0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//:26
  0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//;27
  0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//<28
  0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//=29
  0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//>30
  0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//?31
  0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@32
  0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A33
  0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B34
  0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C35
  0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D36
  0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E37
  0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F38
  0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G39
  0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H40
  0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I41
  0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J42
  0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K43
  0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L44
  0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M45
  0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N46
  0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O47
  0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P48
  0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q49
  0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R50
  0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S51
  0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T52
  0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U53
  0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V54
  0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W55
  0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X56
  0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y57
  0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z58
  0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[59
  0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,//\60
  0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//]61
  0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^62
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_63
  0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//`64
  0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a65
  0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b66
  0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c67
  0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d68
  0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e69
  0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f70
  0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g71
  0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h72
  0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i73
  0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j74
  0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k75
  0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l76
  0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m77
  0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n78
  0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o79
  0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p80
  0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q81
  0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r82
  0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s83
  0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t84
  0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u85
  0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v86
  0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w87
  0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x88
  0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y89
  0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z90
  0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{91
  0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//|92
  0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//}93
  0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~94

};

//------------------------------------------------------------------------------
void ST7565OutChar8X16(unsigned char ucX, unsigned char ucY, unsigned char ucChar) {
    unsigned char i;
    int nBiase;
    
    if(ucChar > ' ')  ucChar -= ' ';    
    nBiase = ucChar;
    nBiase *= 16;
    
    ST7565GotoXY(ucX, ucY);
    for(i = 0; i < 8; i++) ST7565Data(F8X16[nBiase ++]);
    ST7565GotoXY(ucX, ucY + 1);
    for(i = 0; i < 8; i++) ST7565Data(F8X16[nBiase ++]);    
}

void ST7565OutChar6X8(unsigned char ucX, unsigned char ucY, unsigned char ucChar) {
    unsigned char i;
    int nBiase;
    
    if(ucChar > ' ')  ucChar -= ' ';    
    nBiase = ucChar;
    
    ST7565GotoXY(ucX, ucY);
    for(i = 0; i < 6; i++) ST7565Data(F6x8[nBiase][i]);    
}

//------------------------------------------------------------------------------
void ST7565OutString8X16(unsigned char ucX, unsigned char ucY, char * p) {
    unsigned char c;
    while(*(p)) {
        c = *(p ++);
        ST7565OutChar8X16(ucX, ucY, c);
        ucX += 8;
    }
    
}

void ST7565OutString6X8(unsigned char ucX, unsigned char ucY, char * p) {
    unsigned char c;
    while(*(p)) {
        c = *(p ++);
        ST7565OutChar6X8(ucX, ucY, c);
        ucX += 6;
    }    
}

/*
void ST7565OutString8X16C(unsigned char ucX, unsigned char ucY, const char * p) {
    unsigned char c;
    while(*(p)) {
        c = *(p ++);
        ST7565OutChar8X16(ucX, ucY, c);
        ucX += 8;
    }
    
}
void ST7565OutString6X8C(unsigned char ucX, unsigned char ucY, const char * p) {
    unsigned char c;
    while(*(p)) {
        c = *(p ++);
        ST7565OutChar6X8(ucX, ucY, c);
        ucX += 6;
    }
    
}
*/

//==============================================================================
//                END OF THE FILE : ST7565.C
//------------------------------------------------------------------------------

 

03测试


下面是测试串口命令的相关命令:

    else IFARG0("set") {
        sscanf(SDA(1), "%x", &nX);
        sscanf(SDA(2), "%x", &nY);
        sscanf(SDA(3), "%x", &nData);
        ST7565GotoXY(nX, nY);     
        ST7565Data((unsigned char)nData);        
//        printf("%x %x %x", nX, nY, nData);
    } else IFARG0("clear") {
        sscanf(SDA(1), "%x", &nX);
        ST7565Clear((unsigned char)nX);
    } else IFARG0("line") {
        for(nX = 0; nX < 64; nX ++) {
            ST7565SetPoint(nX, nX);
        }

    } else IFARG0("c16") {
        sscanf(SDA(1), "%x", &nX);
        sscanf(SDA(2), "%x", &nY);
        sscanf(SDA(3), "%c", &c);
        ST7565OutChar8X16(nX, nY, c);
        
    } else IFARG0("c8") {
        sscanf(SDA(1), "%x", &nX);
        sscanf(SDA(2), "%x", &nY);
        sscanf(SDA(3), "%c", &c);
        ST7565OutChar6X8(nX, nY, c);
        
    } else IFARG0("s16") {
        sscanf(SDA(1), "%x", &nX);
        sscanf(SDA(2), "%x", &nY);
        ST7565OutString8X16(nX, nY, SDA(3));
    } else IFARG0("s8") {
        sscanf(SDA(1), "%x", &nX);
        sscanf(SDA(2), "%x", &nY);
        ST7565OutString6X8(nX, nY, SDA(3));
    }

▲ 输出字符

▲ 输出字符

 

04:结论


1.LQ-COG12864

改变接口对应的顺序:

特别注意:需要外部将RST上拉到VCC;

▲ LQ-COG1284

▲ LQ-COG1284

2.TOPWAY LM6063A

使用和上面定义相同的交叉引线; 同样需要将RST上拉10k至VCC。

▲ ###gs 2.TOPWAY LM6063

▲ ###gs 2.TOPWAY LM6063

▲ 外部管脚定义

▲ 外部管脚定义

通过上面的测试,可以看到基于ST7565R控制器外部接口具有通用方式。
对于不同的LCD,需要调整相应的初始化的参数:对比度,以及对应的坐标进行调整。

■ 相关文献链接:


  1. 实验板的工程文件,基于ADC815:AD\ADuC845\2020\TestLCD7565R.PcbDoc * ↩︎

  2. TestLCD工程文件:C51\ADuC845\Test\2020\TestLCD\TestLCD.uvproj ↩︎

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐