今天小编要和大家分享的是控制,MCU相关信息,接下来我将从51单片机对LCD1602液晶显示的驱动控制设计,hych228e液晶显示器这几个方面来介绍。

控制,MCU相关技术文章51单片机对LCD1602液晶显示的驱动控制设计hych228e液晶显示器

控制,MCU相关技术文章51单片机对LCD1602液晶显示的驱动控制设计

利用串行A/D转换器TLC549对输入信号电压源进行采集转换成数字信号给51单片机,经单片机进行数据处理后给1602液晶显示。

误差小于1%.

#include

#include

#define uint unsigned int

#define uchar unsigned char

uchar LCD[6]; //电压数据转换成LCD1602液晶字符显示

uint Volt;

sbit DO= P1^0; //时钟

sbit CS= P1^1; //片选

sbit CLK = P1^2; //数据输出

sbit RS = P2^0; //1602液晶数据/命令选择端

sbit RW = P2^1; //1602液晶读写端

sbit E= P2^2; //1602液晶使能端

// Function Prototypes

void check_busy(void);

void write_command(uchar com);

void write_date(uchar date);

void LCD_init(void);

void string(uchar ad ,uchar *s);

//void lcd_test(void);

void delay(uint);

void Volt_To_LCD1602(void);

void delay_ms(uint xms);

void Data_Conversion(void);

uchar TLC549_ADC(void);

/*******************************************

LCD1602 Driver mapped as IO peripheral

*******************************************/

// Delay

// Delay

void delay(uint j)

{

uchar i = 60;

for(; j》0; j--)

{

while(--i);

i = 59;

while(--i);

i = 60;

}

}

// Test the Busy bit

void check_busy(void)

{

do

{

P0 = 0xff;

E = 0;

RS = 0;

RW = 1;

E = 1;

_nop_();

} while(P0 & 0x80);

E = 0;

}

// Write a command

void write_command(uchar com)

{

check_busy();

E = 0;

RS = 0;

RW = 0;

P0 = com;

E = 1;

_nop_();

E = 0;

delay(1);

}

// Write Data

void write_date(uchar date)

{

check_busy();

E = 0;

RS = 1;

RW = 0;

P0 = date;

E = 1;

_nop_();

E = 0;

delay(1);

}

// Initialize LCD controller

void LCD_init(void)

{

write_command(0x38); // 8-bits, 2 lines, 7x5 dots

write_command(0x0C); // no cursor, no blink, enable display

write_command(0x06); // auto-increment on

write_command(0x01); // clear screen

delay(1);

}

// Display a string

void string(uchar ad, uchar *s)