单片机用的是STM8S103K3,用HT1621B驱动一个四com的断码液晶,折腾好几天了,就是不成功。在论坛看了不少例程,也照着改了还是不成。实在没辙贴出照论坛源码修改的程序,望高人指教。基本外围:晶振11.0592,VCC3.3V,VLCD2.75V。液晶共17PIN,用四个com,和SEGO~SEG12。通电后,液晶无显示,测量HT1621引脚电压,CS脚为0V,WR为3.2,DATA为0.7V,SEG0~SEG12和COM全部都是2.75V。请指教。
#include "ioSTM8S103k3.h"
#include <intrinsics.h>
#define uchar unsigned char
#define uint unsigned int
#define BIAS 0x52 //0b1000 0101 0010 1/3duty 4com
#define SYSDIS 0X00 //0b1000 0000 0000 关振系统荡器和LCD偏压发生器
#define SYSEN 0X02 //0b1000 0000 0010 打开系统振荡器
#define LCDOFF 0X04 //0b1000 0000 0100 关LCD偏压
#define LCDON 0X06 //0b1000 0000 0110 打开LCD偏压
#define XTAL 0x28 //0b1000 0010 1000 外部接时钟
#define RC256 0X30 //0b1000 0011 0000 内部时钟
#define TONEON 0X12 //0b1000 0001 0010 打开声音输出
#define TONEOFF 0X10 //0b1000 0001 0000 关闭声音输出
#define WDTDIS 0X0A //0b1000 0000 1010 禁止看门狗
//HT1621控制位(液晶模块接口定义,根据自已的需要更改)
#define CLS_HT_WR() PD_ODR_ODR3 = 0 //拉低
#define SET_HT_WR() PD_ODR_ODR3 = 1 //拉高
#define CLS_HT_CS() PD_ODR_ODR4 = 0 //拉低
#define SET_HT_CS() PD_ODR_ODR4 = 1 //拉高
#define HT1621_DAT PD_ODR_ODR2 //数据位
#define SET_HT_DATA() PD_ODR_ODR2 = 1 //数据位
#define CLS_HT_DATA() PD_ODR_ODR2 = 0 //数据位
void CLK_Init(void)
{
CLK_ECKR=0x01; //外部时钟寄存器 外部时钟准备就绪,外部时钟开
CLK_SWCR=0x02; //切换控制寄存器 使能自动切换机制
CLK_SWR=0xB4; //主时钟切换寄存器 选择HSE为主时钟源
while (!(CLK_SWCR & 0x08));
CLK_CSSR=0x01; //时钟安全系统寄存器
}
void port_init(void)
{
PB_DDR = 0x10;
PB_CR1 = 0x10;
PB_CR2 = 0x0;
PD_DDR = 0x1c;
PD_CR1 = 0x1c;
PD_CR2 = 0x0;
}
void delay(void)
{
unsigned char i;
for (i = 16; i > 0; i--) //16
{
asm("nop"); ;
}
}
void SendBit_1621(unsigned char data, unsigned char cnt) //data的高cnt位写入HT1621,高位在前
{
unsigned char i;
for (i = 0; i < cnt; i++)
{
if ((data & 0x80) == 0)
{
CLS_HT_DATA();
}
else
{
SET_HT_DATA();
}
delay();
CLS_HT_WR();
// delay();
SET_HT_WR();
//delay();
data <<= 1;
}
}
void SendDataBit_1621(unsigned char data, unsigned char cnt) //data的低cnt位写入HT1621,低位在前
{
unsigned char i;
for (i = 0; i < cnt; i++)
{
if ((data & 0x01) == 0)
{
CLS_HT_DATA();
}
else
{
SET_HT_DATA();
}
delay();
CLS_HT_WR();
//delay();
SET_HT_WR();
//delay();
data >>= 1;
}
}
void SendCmd(unsigned char command)
{
CLS_HT_CS();
SendBit_1621(0x80,3); //写入标志码"100"
SendBit_1621(command,9); //写入9 位数据,其中前8 位为command 命令,最后1 位任意
SET_HT_CS();
}
void Write_1621(unsigned char addr, unsigned char data)
{
CLS_HT_CS();
SendBit_1621(0xa0,3); //写入标志码"101"
SendBit_1621(addr << 2,6); //写入6 位addr
SendDataBit_1621(data<<4,4); //写入data 的低4 位
SET_HT_CS();
}
void WriteAll_1621(unsigned char addr, unsigned char * p, unsigned char cnt)
{
unsigned char i;
CLS_HT_CS();
SendBit_1621(0xa0,3); //写入标志码"101"
SendBit_1621(addr << 2,6); //写入6 位addr
for(i =0; i <cnt; i ++,p++) //连续写入数据
{
SendDataBit_1621(*p,8);
}
SET_HT_CS();
}
void Writetest_1621(void)
{
unsigned int i,p;
CLS_HT_CS();
SendBit_1621(0xa0,3); //写入标志码"101"
SendBit_1621(0,6); //写入6 位addr
for (p = 0; p < 32; p++)
{
for(i = 0; i < 8; i ++) //连续写入数据
{
SendDataBit_1621(p,8);
delay();
}
}
SET_HT_CS();
}
void Cls_1621(void)
{
unsigned int i,p;
CLS_HT_CS();
SendBit_1621(0xa0,8); //写入标志码"101"
SendBit_1621(0,6); //写入6 位addr
for (p = 0; p < 32; p++)
{
for(i = 0; i < 8; i ++) //连续写入数据
{
SendDataBit_1621(0,8);
delay();
}
}
SET_HT_CS();
}
//==============================================================================
void main(void)
{
CLK_Init();
port_init();
SendCmd(BIAS); //设置偏压和占空比
SendCmd(SYSEN); //打开系统振荡器
SendCmd(LCDON); //打开LCD偏压发生器
while (1)
{
Write_1621(0x00,0x09);
Write_1621(0x01,0x0f);
Write_1621(0x02,0x00);
Write_1621(0x03,0x0d);
Write_1621(0x04,0x0e);
Write_1621(0x05,0x0f);
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
#include "string.h"
#include "common.h"
#if 0
#define DISP_SEG_S1 (lcd_disp_ram[0] |= SEG_S_COL_DAY_P_TONG)
#define CLEAR_SEG_S1 (lcd_disp_ram[0] &= (~SEG_S_COL_DAY_P_TONG)
#define DISP_SEG_COL1 (lcd_disp_ram[1] |= SEG_S_COL_DAY_P_TONG)
#define CLEAR_SEG_COL1 (lcd_disp_ram[1] &= (~SEG_S_COL_DAY_P_TONG)
#define DISP_SEG_S2 (lcd_disp_ram[2] |= SEG_S_COL_DAY_P_TONG)
#define CLEAR_SEG_S2 (lcd_disp_ram[2] &= (~SEG_S_COL_DAY_P_TONG)
#define DISP_SEG_COL2 (lcd_disp_ram[3] |= SEG_S_COL_DAY_P_TONG)
#define CLEAR_SEG_COL2 (lcd_disp_ram[3] &= (~SEG_S_COL_DAY_P_TONG)
#define DISP_SEG_S3 (lcd_disp_ram[4] |= SEG_S_COL_DAY_P_TONG)
#define CLEAR_SEG_S3 (lcd_disp_ram[4] &= (~SEG_S_COL_DAY_P_TONG)
#define DISP_SEG_P (lcd_disp_ram[5] |= SEG_S_COL_DAY_P_TONG)
#define CLEAR_SEG_P (lcd_disp_ram[5] &= (~SEG_S_COL_DAY_P_TONG)
#define DISP_SEG_DAY (lcd_disp_ram[6] |= SEG_S_COL_DAY_P_TONG)
#define CLEAR_SEG_DAY (lcd_disp_ram[6] &= (~SEG_S_COL_DAY_P_TONG)
#define DISP_SEG_TONG (lcd_disp_ram[7] |= SEG_S_COL_DAY_P_TONG)
#define CLEAR_SEG_TONG (lcd_disp_ram[7] &= (~SEG_S_COL_DAY_P_TONG)
#define DISP_SEG_S4 (lcd_disp_ram[8] |= SEG_S4_T1_COLD_MOTOR)
#define CLEAR_SEG_S4 (lcd_disp_ram[8] &= (~SEG_S4_T1_COLD_MOTOR)
#define DISP_SEG_T1 (lcd_disp_ram[9] |= SEG_S4_T1_COLD_MOTOR)
#define CLEAR_SEG_T1 (lcd_disp_ram[9] &= (~SEG_S4_T1_COLD_MOTOR)
#define DISP_SEG_COLD (lcd_disp_ram[10] |= SEG_S4_T1_COLD_MOTOR)
#define CLEAR_SEG_COLD (lcd_disp_ram[10] &= (~SEG_S4_T1_COLD_MOTOR)
#define DISP_SEG_MOTOR (lcd_disp_ram[11] |= SEG_S4_T1_COLD_MOTOR)
#define CLEAR_SEG_MOTOR (lcd_disp_ram[11] &= (~SEG_S4_T1_COLD_MOTOR)
#define DISP_SEG_HOUR (lcd_disp_ram[8] |= SEG_HOUR_T2_ERR_ICEWATER)
#define CLEAR_SEG_HOUR (lcd_disp_ram[8] &= (~SEG_HOUR_T2_ERR_ICEWATER)
#define DISP_SEG_T2 (lcd_disp_ram[9] |= SEG_HOUR_T2_ERR_ICEWATER)
#define CLEAR_SEG_T2 (lcd_disp_ram[9] &= (~SEG_HOUR_T2_ERR_ICEWATER)
#define DISP_SEG_ERR (lcd_disp_ram[10] |= SEG_HOUR_T2_ERR_ICEWATER)
#define CLEAR_SEG_ERR (lcd_disp_ram[10] &= (~SEG_HOUR_T2_ERR_ICEWATER)
#define DISP_SEG_ICEWATER (lcd_disp_ram[11] |= SEG_HOUR_T2_ERR_ICEWATER)
#define CLEAR_SEG_ICEWATER (lcd_disp_ram[11] &= (~SEG_HOUR_T2_ERR_ICEWATER)
#define DISP_SEG_L (lcd_disp_ram[8] |= SEG_L_T3_HOT_COLDWATER)
#define CLEAR_SEG_L (lcd_disp_ram[8] &= (~SEG_L_T3_HOT_COLDWATER)
#define DISP_SEG_T3 (lcd_disp_ram[9] |= SEG_L_T3_HOT_COLDWATER)
#define CLEAR_SEG_T3 (lcd_disp_ram[9] &= (~SEG_L_T3_HOT_COLDWATER)
#define DISP_SEG_HOT (lcd_disp_ram[10] |= SEG_L_T3_HOT_COLDWATER)
#define CLEAR_SEG_HOT (lcd_disp_ram[10] &= (~SEG_L_T3_HOT_COLDWATER)
#define DISP_SEG_COLDWATER (lcd_disp_ram[11] |= SEG_L_T3_HOT_COLDWATER)
#define CLEAR_SEG_COLDWATER (lcd_disp_ram[11] &= (~SEG_L_T3_HOT_COLDWATER)
#define DISP_SEG_MINUTE (lcd_disp_ram[8] |= SEG_MINUTE_T4_TIME_HOTWATER)
#define CLEAR_SEG_MINUTE (lcd_disp_ram[8] &= (~SEG_MINUTE_T4_TIME_HOTWATER)
#define DISP_SEG_T4 (lcd_disp_ram[9] |= SEG_MINUTE_T4_TIME_HOTWATER)
#define CLEAR_SEG_T4 (lcd_disp_ram[9] &= (~SEG_MINUTE_T4_TIME_HOTWATER)
#define DISP_SEG_TIME (lcd_disp_ram[10] |= SEG_MINUTE_T4_TIME_HOTWATER)
#define CLEAR_SEG_TIME (lcd_disp_ram[10] &= (~SEG_MINUTE_T4_TIME_HOTWATER)
#define DISP_SEG_HOTWATER (lcd_disp_ram[11] |= SEG_MINUTE_T4_TIME_HOTWATER)
#define CLEAR_SEG_HOTWATER (lcd_disp_ram[11] &= (~SEG_MINUTE_T4_TIME_HOTWATER)
#define DISP_SEG_CLOSE (lcd_disp_ram[8] |= SEG_CLOSE_OPEN_ICE)
#define CLEAR_SEG_CLOSE (lcd_disp_ram[8] &= (~SEG_CLOSE_OPEN_ICE)
#define DISP_SEG_OPEN (lcd_disp_ram[9] |= SEG_CLOSE_OPEN_ICE)
#define CLEAR_SEG_OPEN (lcd_disp_ram[9] &= (~SEG_CLOSE_OPEN_ICE)
#define DISP_SEG_ICE (lcd_disp_ram[10] |= SEG_CLOSE_OPEN_ICE)
#define CLEAR_SEG_ICE (lcd_disp_ram[10] &= (~SEG_CLOSE_OPEN_ICE)
#define DISP_SEG_REMAIN (lcd_disp_ram[8] |= SEG_REMAIN_T5_BLANCE)
#define CLEAR_SEG_REMIAN (lcd_disp_ram[8] &= (~SEG_REMAIN_T5_BLANCE)
#define DISP_SEG_T5 (lcd_disp_ram[9] |= SEG_REMAIN_T5_BLANCE)
#define CLEAR_SEG_T5 (lcd_disp_ram[9] &= (~SEG_REMAIN_T5_BLANCE)
#define DISP_SEG_BLANCE (lcd_disp_ram[10] |= SEG_REMAIN_T5_BLANCE)
#define CLEAR_SEG_BLANCE (lcd_disp_ram[10] &= (~SEG_REMAIN_T5_BLANCE)
#define DISP_SEG_CLEAR (lcd_disp_ram[8] |= SEG_CLEAR_INPUT_KEEPTEMP)
#define CLEAR_SEG_CLEAR (lcd_disp_ram[8] &= (~SEG_CLEAR_INPUT_KEEPTEMP)
#define DISP_SEG_INPUT (lcd_disp_ram[9] |= SEG_CLEAR_INPUT_KEEPTEMP)
#define CLEAR_SEG_INPUT (lcd_disp_ram[9] &= (~SEG_CLEAR_INPUT_KEEPTEMP)
#define DISP_SEG_KEEPTEMP (lcd_disp_ram[10] |= SEG_CLEAR_INPUT_KEEPTEMP)
#define CLEAR_SEG_KEEPTEMP (lcd_disp_ram[10] &= (~SEG_REMAIN_T5_BLANCE)
#define DISP_SEG_STOP (lcd_disp_ram[8] |= SEG_STOP_CN_PRICE)
#define CLEAR_SEG_STOP (lcd_disp_ram[8] &= (~SEG_STOP_CN_PRICE)
#define DISP_SEG_CN (lcd_disp_ram[9] |= SEG_STOP_CN_PRICE)
#define CLEAR_SEG_CN (lcd_disp_ram[9] &= (~SEG_STOP_CN_PRICE)
#define DISP_SEG_PRICE (lcd_disp_ram[10] |= SEG_STOP_CN_PRICE)
#define CLEAR_SEG_PRICE (lcd_disp_ram[10] &= (~SEG_STOP_CN_PRICE)
#define LCD_DIGIT_LENGTH 8
#endif
#if 0
//Err Code
const u8 ser_num_err[3]={0,0,1}; //非本系统卡
const u8 user_limit_err[3]={0,0,2}; //限制到达
const u8 user_blance_err[3]={0,0,3}; //钱包错误
const u8 ManageErr[8]={0,0,4}; //管理卡错误
//const u8 LostErr[8]={0x79,0x40,0x40,0x40,0x40,0x3F,0x3F,0x6D}; //挂失错误
//const u8 SortErr[8]={0x79,0x40,0x40,0x40,0x40,0x3F,0x3F,0x7D}; //采集错误
//const u8 SetErr[8]={0x79,0x40,0x40,0x40,0x40,0x3F,0x3F,0x07}; //设置错误
//const u8 RsComErr[8]={0x79,0x40,0x40,0x40,0x40,0x3F,0x3F,0x7F}; //串口通信错误
const u8 SystemParaErr[3]={0,0,9}; //参数错误
const u8 user_card_lost[3]={0,1,0}; //消费卡已经挂失
const u8 user_group_err[3]={0,1,1}; //采集卡序组号错误
const u8 SortCardFull[3]={0,1,2};//采集卡漫
const u8 user_card_valid[3] = {0,1,3}; //有效期到达
const u8 user_card_type[3] = {0,1,4};
//Success code
//const u8 LostSucc[8]={0x3F,0x40,0x40,0x40,0x40,0x3F,0x3F,0x06}; //挂失成功
//const u8 SortSucc[8]={0x3F,0x40,0x40,0x40,0x40,0x3F,0x3F,0x5B}; //采集成功
//const u8 RsComSucc[8]={0x3F,0x40,0x40,0x40,0x40,0x3F,0x3F,0x4F}; //串口通信成功
//const u8 SetSucc[8]={0x3F,0x40,0x40,0x40,0x40,0x3F,0x3F,0x66};
const u8 ManageSucc[3]={0,0,4};
//Other disp code
//const u8 Logo[3] = {0x40,0x6D,0x37,0x79,0x78,0x40}; //SNET
//const u8 GL_Card[3] = {0x40,0x71,0x3E,0x37,0x39,0x40}; //--FUNC--
//const u8 GS_Card[3] = {0x40,0x38,0x3F,0x6D,0x78,0x40};//--LOST--
//const u8 PC_CON[8] = {0x40,0x73,0x39,0x40,0x39,0x3F,0x37,0x40}; //-PC-CON-
//const u8 SORT_CARD[3]={0x40,0x6D,0x3F,0x6F,0x5E,0x40};//采集
//const u8 SET_CARD[3]={0x40,0x6D,0x79,0x07,0x40,0x40}; //设置
//const u8 SC_CARD[8]={0x40,0x40,0x40,0x6D,0x39,0x40,0x40,0x40}; //生产
#endif
void lcd_write_bit(u8 lcd_bit,u8 lcd_write_cnt)
{
u8 i;
RTC_LCD_SCK_H;
nop();nop();nop();nop();nop();nop();
for(i=0;i<lcd_write_cnt;i++)
{
delay_10us(1);
RTC_LCD_SCK_L;
if((lcd_bit & 0x80) == 0x80)
RTC_LCD_IO_H;
else
RTC_LCD_IO_L;
delay_10us(1);
RTC_LCD_SCK_H;
nop();nop();nop();nop();nop();nop();
lcd_bit <<= 1;
RTC_LCD_SCK_H;
}
}
void lcd_cmd_mode(void)
{
lcd_write_bit(0x80,3);
}
void lcd_data_mode(void)
{
lcd_write_bit(0xA0,3);
}
void lcd_write_cmd(u8 lcd_cmd)
{
lcd_write_bit(lcd_cmd, 8);
delay_10us(1);
RTC_LCD_IO_H;
delay_10us(1);
RTC_LCD_SCK_L;
delay_10us(1);
RTC_LCD_SCK_H;
}
void lcd_write_addr(u8 lcd_ram_addr)
{
lcd_ram_addr <<= 2; //ram Hight 2 bit need ingron
lcd_write_bit(lcd_ram_addr, 6);
}
void lcd_write_data(u8 lcd_ram_data)
{
u8 i;
RTC_LCD_SCK_H;
nop();nop();nop();nop();
for(i=0;i<8;i++)
{
delay_10us(1);
RTC_LCD_SCK_L;
if((lcd_ram_data & 0x01) == 0x01)
RTC_LCD_IO_H;
else
RTC_LCD_IO_L;
delay_10us(1);
RTC_LCD_SCK_L;
nop();nop();nop();nop();
lcd_ram_data >>= 1;
RTC_LCD_SCK_H;
}
}
***************************************************************************/
#include "ioSTM8S103k3.h"
#include <intrinsics.h>
#define uchar unsigned char
#define uint unsigned int
#define BIAS 0x52 //0b1000 0101 0010 1/3duty 4com
#define SYSDIS 0X00 //0b1000 0000 0000 关振系统荡器和LCD偏压发生器
#define SYSEN 0X02 //0b1000 0000 0010 打开系统振荡器
#define LCDOFF 0X04 //0b1000 0000 0100 关LCD偏压
#define LCDON 0X06 //0b1000 0000 0110 打开LCD偏压
#define XTAL 0x28 //0b1000 0010 1000 外部接时钟
#define RC256 0X30 //0b1000 0011 0000 内部时钟
#define TONEON 0X12 //0b1000 0001 0010 打开声音输出
#define TONEOFF 0X10 //0b1000 0001 0000 关闭声音输出
#define WDTDIS 0X0A //0b1000 0000 1010 禁止看门狗
//HT1621控制位(液晶模块接口定义,根据自已的需要更改)
#define CLS_HT_WR PD_ODR_ODR3 = 0 //拉低
#define SET_HT_WR PD_ODR_ODR3 = 1 //拉高
#define CLS_HT_CS PD_ODR_ODR4 = 0 //拉低
#define SET_HT_CS PD_ODR_ODR4 = 1 //拉高
#define HT1621_DAT PD_ODR_ODR2 //数据位
#define SET_HT_DAT PD_ODR_ODR2 = 1 //数据位
#define CLS_HT_DAT PD_ODR_ODR2 = 0 //数据位
/*void CLK_Init(void)
{
CLK_ECKR=0x01; //外部时钟寄存器 外部时钟准备就绪,外部时钟开
CLK_SWCR=0x02; //切换控制寄存器 使能自动切换机制
CLK_SWR=0xB4; //主时钟切换寄存器 选择HSE为主时钟源
while (!(CLK_SWCR & 0x08));
CLK_CSSR=0x01; //时钟安全系统寄存器
}*/
void port_init(void)
{
PB_DDR = 0x80;
PB_CR1 = 0x80;
PB_CR2 = 0x0;
PD_DDR = 0x1c;
PD_CR1 = 0x1c;
PD_CR2 = 0x0;
}
void Init()
{
CLK_ICKR |= 0x01; //打开内部高速RC
CLK_CKDIVR = 0x10; //HSI--4MHZ
}
//-----------------------------------------------------------------------------------------
//函数名称:Delay()
//功 能:延时子程序
//-----------------------------------------------------------------------------------------
void Delay(uchar us) //5,7,9
{
while(--us);
}
//-----------------------------------------------------------------------------------------
//函数名称:DelayMS()
//功 能:延时子程序
//-----------------------------------------------------------------------------------------
void DelayMS(uint iMs)
{
uint i,j;
for(i=0;i<iMs;i++)
for(j=0;j<65;j++)
{
Delay(1);
}
}
//-----------------------------------------------------------------------------------------
//函数名称:Ht1621Wr_Data()
//功 能:写数据函数,cnt为传送数据位数,数据传送为低位在前
//-----------------------------------------------------------------------------------------
void Ht1621Wr_Data(uchar Data,uchar cnt)
{
uchar i;
for (i=0;i<cnt;i++)
{
CLS_HT_WR; //HT1621_WR=0;
asm("nop");
asm("nop");
asm("nop");
asm("nop");
if((Data & 0x80)==0x80)
{
SET_HT_DAT; //HT1621_DAT=1;
}
else
{
CLS_HT_DAT; //HT1621_DAT=0;
}
SET_HT_WR; //HT1621_WR=1;
asm("nop");
asm("nop");
asm("nop");
asm("nop");
Data<<=1;
}
}
//-----------------------------------------------------------------------------------------
//函数名称:void Ht1621WrOneData(uchar Addr,uchar Data)
//功能描述: HT1621在指定地址写入数据函数
//参数说明:Addr为写入初始地址,Data为写入数据
//说 明:因为HT1621的数据位4位,所以实际写入数据为参数的后4位
//-----------------------------------------------------------------------------------------
void Ht1621WrOneData(uchar Addr,uchar Data)
{
CLS_HT_CS; //HT1621_CS=0;
Ht1621Wr_Data(0xa0,3); //写入数据标志101
Ht1621Wr_Data(Addr<<2,6); //写入地址数据
Ht1621Wr_Data(Data<<4,4); //写入数据
SET_HT_CS;//HT1621_CS=1;
}
//-----------------------------------------------------------------------------------------
//函数名称:void Ht1621WrAllData()
//功能描述: HT1621连续写入方式函数
//说 明:HT1621的数据位4位,此处每次数据为8位,写入数据总数按8位计算
//-----------------------------------------------------------------------------------------
void Ht1621WrAllData(void)
{
uchar i;
CLS_HT_CS;//HT1621_CS=0;
Ht1621Wr_Data(0xa0,3); //写入数据标志101
Ht1621Wr_Data(0x00<<2,6); //写入地址数据
for (i=0;i<16;i++)
{
Ht1621Wr_Data(0x00,8); //写入数据
}
SET_HT_CS;//HT1621_CS=1;
}
//-----------------------------------------------------------------------------------------
//函数名称:void Ht1621WrCmd(uchar Cmd)
//功能描述: HT1621命令写入函数
//参数说明:Cmd为写入命令数据
//说 明:写入命令标识位100
//-----------------------------------------------------------------------------------------
void Ht1621WrCmd(uchar Cmd)
{
CLS_HT_CS;//HT1621_CS=0;
asm("nop");
asm("nop");
asm("nop");
asm("nop");
Ht1621Wr_Data(0x80,4); //写入命令标志100
Ht1621Wr_Data(Cmd,8); //写入命令数据
SET_HT_CS;//HT1621_CS=1;
}
//-----------------------------------------------------------------------------------------
//函数名称:void Ht1621_Init(void)
//功能描述: HT1621初始化
//说 明:初始化后,液晶屏所有字段均显示
//-----------------------------------------------------------------------------------------
void Ht1621_Init()
{
SET_HT_CS;//HT1621_CS=1;
SET_HT_WR;//HT1621_WR=1;
SET_HT_DAT;//HT1621_DAT=1;
DelayMS(20); //延时使LCD工作电压稳定
Ht1621WrCmd(BIAS);
Ht1621WrCmd(RC256); //使用内部振荡器
Ht1621WrCmd(SYSDIS);
Ht1621WrCmd(WDTDIS);
Ht1621WrCmd(SYSEN);
Ht1621WrCmd(LCDON);
}
void main( void )
{
uchar i=0x1d;
Init(); //初始化子程序
port_init();
Ht1621_Init(); //上电初始化LCD
DelayMS(50); //延时一段时间
Ht1621WrAllData();
while(1)
{
Ht1621WrOneData(i-16,0x06);//1
Ht1621WrOneData(i-15,0x0e);Ht1621WrOneData(i-14,0x03);//2
Ht1621WrOneData(i-13,0x0a);Ht1621WrOneData(i-12,0x07);//3
Ht1621WrOneData(i-11,0x03);Ht1621WrOneData(i-10,0x06);//4
Ht1621WrOneData(i-9,0x0b);Ht1621WrOneData(i-8,0x05);//5
Ht1621WrOneData(i-7,0x0f);Ht1621WrOneData(i-6,0x05);//6
Ht1621WrOneData(i-5,0x00);Ht1621WrOneData(i-4,0x07);//7
Ht1621WrOneData(i-3,0x0f);Ht1621WrOneData(i-2,0x07);//8
Ht1621WrOneData(i-1,0x0b);Ht1621WrOneData(i,0x07);//9
DelayMS(0xcff);
i=i-2;
if(i==0x01)
{
i = 0x21;
}
}
}
一周热门 更多>