欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
基于msp430單片機的1602顯示源程序
[打印本頁]
作者:
鰥獨境諦
時間:
2018-3-26 17:40
標題:
基于msp430單片機的1602顯示源程序
基于430單片機的1602簡單顯示
單片機源程序如下:
#include "io430.h"
#define RS_di P5OUT &= ~BIT5 //RS置低
#define RS_gao P5OUT |= BIT5 //RS置高
#define RW_di P5OUT &= ~BIT6 //RW置低
#define RW_gao P5OUT |= BIT6 //RW置高
#define EN_di P5OUT &= ~BIT7 //E置低
#define EN_gao P5OUT |= BIT7 //E置高
unsigned char DATA[30]= "feeling tipsy;dispersed;forgot";
//*************************************************************************
// 初始化IO口子程序
//*************************************************************************
void Port_init()
{
P4SEL = 0x00;
P4DIR = 0xFF; //數據口輸出模式
P5SEL = 0x00;
P5DIR|= BIT5 + BIT6 + BIT7; //控制口設置為輸出模式
}
//***********************************************************************
// 顯示屏命令寫入函數
//***********************************************************************
void LCD_write_com(unsigned char com)
{
RS_di;
RW_di;
EN_gao;
P4OUT = com; //命令寫入端口
__delay_cycles(5000);
EN_di;
}
//***********************************************************************
// 顯示屏數據寫入函數
//***********************************************************************
void LCD_write_data(unsigned char data)
{
RS_gao;
RW_di;
EN_gao;
P4OUT = data; //數據寫入端口
__delay_cycles(5000);
EN_di;
}
//***********************************************************************
// 顯示屏清空顯示
//***********************************************************************
void LCD_clear(void)
{
LCD_write_com(0x01); //清屏幕顯示
__delay_cycles(5000);
}
//***********************************************************************
// 顯示屏初始化函數
//***********************************************************************
void LCD_init(void)
{
LCD_write_com(0x38); //顯示模式設置
__delay_cycles(5000);
LCD_write_com(0x08); //顯示關閉
__delay_cycles(500);
LCD_write_com(0x01); //顯示清屏
__delay_cycles(5000);
LCD_write_com(0x06); //顯示光標移動設置
__delay_cycles(5000);
LCD_write_com(0x0C); //顯示開及光標設置
__delay_cycles(5000);
}
//***********************************************************************
// 主程序
//***********************************************************************
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
unsigned char i = 0;
Port_init();
LCD_init();
//LCD_write_data(data);
while(1)
{
if(i<=15)
{
LCD_write_com(0x80+0x00);
for(i=0;i<=15;i++)
{
LCD_write_data(DATA[i]);
}
}
else
{
LCD_write_com(0x80+0x40+0x00);
for(i=16;i<=29;i++)
{
LCD_write_data(DATA[i]);
}
}
// LCD_write_data(data);
}
}
復制代碼
所有資料51hei提供下載:
1602xian_shi.zip
(178.43 KB, 下載次數: 6)
2018-3-26 17:39 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1