HT1621 Test Procedure

Publisher:码农侠Latest update time:2016-09-09 Source: eefocusKeywords:HT1621 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
/****************************************************** *******

Functional description: HT1621 chip test program

Description: This test program can test every field of HT1621.

            Light up each field in turn

Parameters:
************************************************ ********/
#include
#include
#define uchar unsigned char
#define uint unsigned int

#define _Nop() _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_()
#define BIAS 0x52 //0b1000 0101 0010 1/3duty 4com

#define SYSDIS 0X00 //0b1000 0000 0000 Turn off the system oscillator and LCD bias generator
#define SYSEN 0X02 //0b1000 0000 0010 Turn on the system oscillator

#define LCDOFF 0X04 //0b1000 0000 0100 Turn off LCD bias
#define LCDON 0X06 //0b1000 0000 0110 Turn on LCD bias
#define XTAL 0x28 //0b1000 0010 1000 External clock
#define RC256 0X30 //0b1000 0011 0000 Internal clock
#define TONEON 0X12 //0b1000 0001 0010 Turn on sound output
#define TONEOFF 0X10 //0b1000 0001 0000 Turn off sound output
#define WDTDIS 0X0A //0b1000 0000 1010 Disable watchdog

//HT1621 control bit (LCD module interface definition, change according to your own needs)
sbit HT1621_DAT=P3^4; //HT1621 data pin
sbit HT1621_CS=P3^2; //HT1621 enable pin
sbit HT1621_WR=P3^3; //HT1621 clock pin uchar
code Ht1621Tab[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

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

//delay us
void Delay(uchar us) //5,7,9
{
 while(--us);
}


//delay ms
void DelayMS(uint iMs)
{
 uint i,j;
 for(i=0;i  for(j=0;j<65;j++) Delay(1);
}

/**********************************************************
Write data function, cnt is the number of data bits to be transmitted, data is transmitted with the low bit first
*******************************************************/
void Ht1621Wr_Data (ucharData ,uchar cnt)
{
 uchar i;
 for (i=0;i       {
       HT1621_WR=0;
       _Nop();
       HT1621_DAT=Data &0x80;
       _Nop();
       HT1621_WR=1;
       _Nop();
      Data <<=1;
     }

}

/********************************************************
Function name: void Ht1621WrCmd (uchar Cmd)
Function description: HT1621 command write function
Global variables: None
Parameter description: Cmd is the write command data
Return description: None

Description: Write command flag 100
*****************************************************/
void Ht1621WrCmd(uchar Cmd)
{
 HT1621_CS=0;
 _Nop();
 Ht1621Wr_Data (0x80,4); //Write command flag 100
 Ht1621Wr_Data (Cmd,8); //Write command data
 HT1621_CS=1;
 _Nop();
}
/********************************************************
Function name: void Ht1621WrOneData(uchar Addr,uchar Data )
Function description: HT1621 writes data at the specified address
Global variables: None
Parameter description: Addr is the initial address to write, Data is the data to write
Return description:
None Note: Because the data bit of HT1621 is 4 bits, the actual written data is the last 4 bits of the parameter
**********************************************************/
void Ht1621WrOneData(uchar Addr,uchar Data)
{
 HT1621_CS=0;
 Ht1621Wr_Data (0xa0,3); //Write data flag 101
 Ht1621Wr_Data (Addr<<2,6); //Write address data
 Ht1621Wr_Data (Data <<4,4); //Write data
 HT1621_CS=1;
 _Nop();
}
/********************************************************
HT1621 test program, 2008-2-13, 22:41:43
Function name: void Ht1621WrAllData(uchar Addr,uchar *p,uchar cnt)
Function description: HT1621 continuous write function
Global variables: None
Parameter description: Addr is the initial write address, *p is the continuous write data pointer,
                  cnt is the total number of written data
Return description: None Description
: HT1621 has 4 data bits, here each data is 8 bits,
           the total number of written data is calculated as 8 bits
****************************************************/
void Ht1621WrAllData(uchar Addr,uchar *p,uchar cnt)
{
 uchar i;
 HT1621_CS=0;
 Ht1621Wr_Data (0xa0,3); //Write data flag 101
 Ht1621Wr_Data (Addr<<2,6); //Write address datafor
 (i=0;i       {
        Ht1621Wr_Data (*p,8); //Write data
        p++;
       }
 HT1621_CS=1;
 _Nop();
}
/********************************************************
Function name: void Ht1621_Init(void)
Function description: HT1621 initialization
Global variables: None
Parameter description: None
Return description: None
Version: 1.0Description
: After initialization, all fields of the LCD screen are displayed
********************************************************/
void Ht1621_Init(void)
{
 HT1621_CS=1;
 HT1621_WR=1;
 HT1621_DAT=1;
 DelayMS(2000); //Delay to stabilize the LCD working voltage
 Ht1621WrCmd(BIAS);
 Ht1621WrCmd(RC256); //Use the internal oscillator
 Ht1621WrCmd(SYSDIS);
 Ht1621WrCmd(WDTDIS);
 Ht1621WrCmd(SYSEN);
 Ht1621WrCmd(LCDON);
}

/**********************************/
void main()
{
 uchar i,j,t;
 Ht1621_Init(); //Power on and initialize LCD
 DelayMS(1000); //Delay for a whilewhile
 (1){
               Ht1621WrAllData(0,Ht1621Tab,16); //Clear 1621 register data, and clear the screenfor
               (i=0;i<32;i++)
                    {
                     t=0x01;
                     for (j=0;j<4;j++)
                          {
                           Ht1621WrOneData(i,t);
                           t<<=1;
                           t++;
                           P1_5=~P1_5;
                           DelayMS(5000);
                          }
                     }
               }
  }

Keywords:HT1621 Reference address:HT1621 Test Procedure

Previous article:Detailed explanation of KeilC51 usage (Part 1)
Next article:Usage of using in Keil C51

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号