MSP430G2553 1602 display characters

Publisher:oplndctkl出Latest update time:2018-07-14 Source: eefocusKeywords:MSP430G2553 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

I checked a lot on the Internet; many people said that it would be easy to use after downloading it, but it was useless. I will write this for myself to read later. It is not very standardized, just for reference. It should be OK to download it, but it is very dark under 3.3V power supply. And 2553 only has a few IO ports after all. If conditions permit, you can waste it like this. The data port of this code is transmitted through P1, but the P1 port has various other commonly used functions. So if you really need to use it, it is better to use P2 as the data port. Just change the port in the code. But a word of advice: be sure to check the IO configuration carefully in the manual. Although there is no big problem in this program

First attach the code directly:

# include "msp430G2553.h"

# define uchar unsigned char 

# define uint unsigned int 

# define LCD1602_RS_H  P2OUT|=BIT0

# define LCD1602_RS_L  P2OUT&=~BIT0

# define LCD1602_RW_H  P2OUT|=BIT1

# define LCD1602_RW_L  P2OUT&=~BIT1

# define LCD1602_EN_H  P2OUT|=BIT2

# define LCD1602_EN_L  P2OUT&=~BIT2

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

Function name: Delay_Nms

Function: Delay Nms (the default internal DCO seems to be 1MHZ)

Function parameters: n

Function return value: None

Additional note: This delay function is not accurate. It is roughly estimated from the time it takes to execute the instruction.

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

void Delay_Nms(uint n)

{

  uint  i,j;

  for(i=250;i>0;i--)

    for(j=n;j>0;j--);

}

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

Function name: Write_1602_Cmd

Function: Write a byte of instruction to 1602

Function parameter: uchar: Cmd

Function return value: None

Additional note: The level of reading the timing diagram is still far from enough and the understanding is far from enough. When writing, the following comments are added 

The result is that it just doesn’t show up!!!

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

void Write_1602_Cmd(uchar Cmd)

{

  LCD1602_RS_H; //RS is low write instruction

  LCD1602_RW_H;

  LCD1602_EN_L;

    

  LCD1602_RS_L;

  LCD1602_RW_L;

  P1OUT=Cmd;

  Delay_Nms(5);

  LCD1602_EN_H;

  Delay_Nms(5);

  LCD1602_EN_L;

  //LCD1602_RW_L;

  //LCD1602_RS_H;

}

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

Function name: Write_1602_Data

Function: Write one byte of data to 1602

Function parameters: uchar: Data

Function return value: None

Additional note: The level of reading the timing diagram is still far from enough and the understanding is far from enough. When writing, the following comments are added 

The result is that it just doesn’t show up!!!

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

void Write_1602_Data(uchar Data)

{

  LCD1602_RS_L;

  LCD1602_RW_L;

  LCD1602_EN_L;

  

  LCD1602_RS_H;

  LCD1602_RW_L;

  P1OUT=Data;

  Delay_Nms(5);

  LCD1602_EN_H;

  Delay_Nms(5);

  LCD1602_EN_L;

 //LCD1602_RS_L;

 //LCD1602_RW_L;

}

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

Function name: Init_1602

Function: Initialize 1602 and IO ports

Function parameters: None

Function return value: None

Additional note: Be sure to read the IO configuration carefully in the manual

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

void Init_1602()

{

  P1DIR|=0xff;

  P1SEL=0;

  P1SEL2=0;

  P2DIR|=BIT0+BIT1+BIT2;

  P2SEL&=~(BIT0+BIT1+BIT2); //Default is 0, optional

  P2SEL2&=~(BIT0+BIT1+BIT2);//Same as above, no need to write, just check the manual IO configuration

  Write_1602_Cmd(0x38);

  Delay_Nms(5);

  Write_1602_Cmd(0x0c);

  Delay_Nms(5);

  Write_1602_Cmd(0x06);

  Delay_Nms(5);

  Write_1602_Cmd(0x01);

}

void main()

{

  WDTCTL = WDTPW + WDTHOLD; // Often forget to turn off the watchdog  

  Heat_1602();

  while(1)

  {

    Write_1602_Cmd(0x80); //Display screen command writing function

    Write_1602_Data('2'); // Display screen data writing function

  }

}


Keywords:MSP430G2553 Reference address:MSP430G2553 1602 display characters

Previous article:MSP430G2253 generates PWM with adjustable duty cycle
Next article:msp430 button control LED light

Recommended ReadingLatest update time:2024-11-22 21:52

PIC16F877A+18B10 temperature measurement+LCD1602 temperature display
;18B10 temperature measurement + LCD 1602 temperature display ;Practical purpose ;1. Learn how to use the 18B20 single bus temperature sensor . ;2. Learn how to use LCD. ;3. Learn how to convert decimal to decimal. ;All resources: ;1. TMRO timer. Generates the delay time required for temperature conversion. ;2. PORTA
[Microcontroller]
Application of PIC microcontroller and 18b20
  #include "1602.h" #include "18b20.h" #include "main.h" __CONFIG(0X0B31); main() {         char msg = {"  Temperature:  ","              .C"};         delay_us2 (40, 40);         delay_us2 (100, 200);         initial();         while(1) {                 start_convert();                 change_to_ascii (get_temp ()
[Microcontroller]
Application of PIC microcontroller and 18b20
MCU MQ-2 smoke detection + ADC0809 AD conversion + lcd1602 display program
The microcontroller source program is as follows: /*============================================================ // //Programming: Mr. Liu Wiring: D0--D7 connected to P0.0-P0.7       ST---P2.3           EOC--P2.2           YOU---P2.1           CLK--P2.0 This program source code is for learning reference only an
[Microcontroller]
MCU MQ-2 smoke detection + ADC0809 AD conversion + lcd1602 display program
LCD1602 liquid crystal display Chinese character display program with simulation
//Create the "工" font and display it in the first row and first column //P155 reference program: GONG_ZI() //MCU simulation file download: http://www.51hei.com/bbs/dpj-23789-1.html  #include reg51.h #include intrins.h //library function header file, the code references the _nop_() function   sbit RS=0xb0; //P
[Microcontroller]
PIC16F887 Serial LCD1602 Button
#include xc.h #include stdio.h #include stdlib.h #include string.h #define uchar unsigned char #define uint unsigned int /* CONFIG1 */ #pragma config FOSC = XT        /* Oscillator Selection bits (XT oscillator: Crystal/resonator on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN) */ #pragma config WDTE = OFF       /* Watchd
[Microcontroller]
Single chip microcomputer + 1602 LCD display design
I spent a busy day making a 1602 display simulation circuit and program. After debugging, it runs normally! ! The feeling of success is really good, haha......... Now share the results with everyone The circuit program is as follows: #include reg51.h #include stdio.h #define uint unsigned int #
[Microcontroller]
Single chip microcomputer + 1602 LCD display design
Using 1602 LCD module to display Chinese characters and graphics
It only takes two steps to use 1602 LCD to display Chinese characters and graphics. And as long as you can use 1602 to display the character 'a', you can immediately display Chinese characters and graphics without writing new operation functions. First, let's briefly explain what we are going to do: The font lib
[Microcontroller]
Using 1602 LCD module to display Chinese characters and graphics
Single chip DHT11 temperature and humidity + 1602 LCD display program
  DHT11 driver reference http://www.51hei.com/bbs/dpj-112282-1.html http://www.51hei.com/bbs/dpj-38067-1.html 1602 driver reference http://www.51hei.com/bbs/dpj-24671-1.html /********************************************************************************************* Program name: DHT11-1602 Written by: fby Dat
[Microcontroller]
Single chip DHT11 temperature and humidity + 1602 LCD display program
Latest Microcontroller Articles
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号