欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標(biāo)題: msp430單片機(jī)的LCD1602顯示程序 [打印本頁(yè)]

作者: 井中月V    時(shí)間: 2018-11-26 08:31
標(biāo)題: msp430單片機(jī)的LCD1602顯示程序
//*************************************************************************
//          初始化IO口子程序
//*************************************************************************
void Port_init()
{

    P4SEL = 0x00;
        P4DIR = 0xFF;                   //數(shù)據(jù)口輸出模式
        P5SEL = 0x00;
        P5DIR|= BIT5 + BIT6 + BIT7;     //控制口設(shè)置為輸出模式
}

//***********************************************************************
//  顯示屏命令寫(xiě)入函數(shù)
//***********************************************************************
void LCD_write_com(unsigned char com)
{
    RS_CLR;
    RW_CLR;
    EN_SET;
    DataPort = com;                 //命令寫(xiě)入端口
    delay_ms(5);
    EN_CLR;
}

//***********************************************************************
//  顯示屏數(shù)據(jù)寫(xiě)入函數(shù)
//***********************************************************************
void LCD_write_data(unsigned char data)
{
    RS_SET;
    RW_CLR;
    EN_SET;
    DataPort = data;                //數(shù)據(jù)寫(xiě)入端口
    delay_ms(5);
    EN_CLR;
}

//***********************************************************************
//  顯示屏清空顯示
//***********************************************************************
void LCD_clear(void)
{
    LCD_write_com(0x01);            //清屏幕顯示
    delay_ms(5);
}

//***********************************************************************
//  顯示屏字符串寫(xiě)入函數(shù)
//***********************************************************************
void LCD_write_str(unsigned char x,unsigned char y,unsigned char *s)
{

    if (y == 0)
    {
        LCD_write_com(0x80 + x);        //第一行顯示
    }
    else
    {
        LCD_write_com(0xC0 + x);        //第二行顯示
    }

    while (*s)
    {
        LCD_write_data( *s);
        s ++;
    }
}

//***********************************************************************
//  顯示屏單字符寫(xiě)入函數(shù)
//***********************************************************************
void LCD_write_char(unsigned char x,unsigned char y,unsigned char data)
{

    if (y == 0)
    {
        LCD_write_com(0x80 + x);        //第一行顯示
    }
    else
    {
        LCD_write_com(0xC0 + x);        //第二行顯示
    }

    LCD_write_data( data);
}

//***********************************************************************
//  顯示屏初始化函數(shù)
//***********************************************************************
void LCD_init(void)
{
    LCD_write_com(0x38);        //顯示模式設(shè)置
    delay_ms(5);
    LCD_write_com(0x08);        //顯示關(guān)閉
    delay_ms(5);
    LCD_write_com(0x01);        //顯示清屏
    delay_ms(5);
    LCD_write_com(0x06);        //顯示光標(biāo)移動(dòng)設(shè)置
    delay_ms(5);
    LCD_write_com(0x0C);        //顯示開(kāi)及光標(biāo)設(shè)置
    delay_ms(5);
}

//***********************************************************************
//      液晶顯示界面初始化
//***********************************************************************
void LCD_Desk(void)
{
  LCD_clear();
  LCD_write_str(0,0,"The Key Number:");
  delay_ms(250);
}








歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1