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
}
/**********************************************************
Write data function, cnt is the number of data bits to be transmitted, data is transmitted with the low bit first
*******************************************************/
void Ht1621Wr_Data
{
uchar i;
for (i=0;i
HT1621_WR=0;
_Nop();
HT1621_DAT=Data
_Nop();
HT1621_WR=1;
_Nop();
Data
}
}
/********************************************************
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
Ht1621Wr_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
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
{
HT1621_CS=0;
Ht1621Wr_Data
Ht1621Wr_Data
Ht1621Wr_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
Ht1621Wr_Data
(i=0;i
Ht1621Wr_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);
}
}
}
}
Previous article:Detailed explanation of KeilC51 usage (Part 1)
Next article:Usage of using in Keil C51
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Is there any room for optimization of simpliciti's power consumption?
- Design of an extremely low power digital thermometer using MSP430
- Eight practical ways to solve Spark data skew
- Will it damage the phone or battery if I play games while charging my phone after it is fully charged?
- [NXP Rapid IoT Review] + Experience of using Rapid IOT Studio
- My goodness, what kind of electronic component is this?
- Record errors encountered in CCS
- How to choose TVS tube for MSP430FR2633 touch chip
- 【RPi PICO】 Pi calculation test
- A classic circuit sharing of 5V and 3.3V level conversion of IIC