標題:
關于在msp430f5529在LCD12864上顯示字符串問題 求幫助
[打印本頁]
作者:
l884859265
時間:
2019-4-9 13:41
標題:
關于在msp430f5529在LCD12864上顯示字符串問題 求幫助
程序功能:測矩形波頻率并輸出在12864上現(xiàn)在問題,頻率測出來啦,存在數(shù)組 lcd_buf 里了,但是通過12864顯示不出來。
請教大佬謝謝!
作者:
l884859265
時間:
2019-4-9 13:42
主函數(shù):
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
Port_init(); //系統(tǒng)初始化,設置IO口屬性
delay_ms(100); //延時100ms
LCD_init(); //液晶參數(shù)初始化設置
LCD_clear(); //清屏
display_desk();
作者:
l884859265
時間:
2019-4-9 13:43
頭文件和12864相關配置
#include <msp430f5529.h>
#include <msp430.h>
#include "stdint.h"
#define uint unsigned int
#define uchar unsigned char
#define CPU_F ((double)8000000)
#define delay_us(x) __delay_cycles((long)(CPU_F*(double)x/1000000.0))
#define delay_ms(x) __delay_cycles((long)(CPU_F*(double)x/1000.0))
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
/*12864應用指令*/
#define CLEAR_SCREEN 0x01 //清屏指令:清屏且AC值為00H
#define AC_INIT 0x02 //將AC設置為00H。且游標移到原點位置
#define CURSE_ADD 0x06 //設定游標移到方向及圖像整體移動方向(默認游標右移,圖像整體不動)
#define FUN_MODE 0x30 //工作模式:8位基本指令集
#define DISPLAY_ON 0x0c //顯示開,顯示游標,且游標位置反白
#define DISPLAY_OFF 0x08 //顯示關
#define CURSE_DIR 0x14 //游標向右移動:AC=AC+1
#define SET_CG_AC 0x40 //設置AC,范圍為:00H~3FH
#define SET_DD_AC 0x80
#define P10 0
#define P11 1
#define P12 2
#define P13 3
#define P14 4
#define P15 5
#define P16 6
#define P17 7
#define RS_CLR P6OUT &= ~(1 << P14) //RS置低
#define RS_SET P6OUT |= (1 << P14) //RS置高
#define RW_CLR P6OUT &= ~(1 << P10) //RW置低
#define RW_SET P6OUT |= (1 << P10) //RW置高
#define EN_CLR P6OUT &= ~(1 << P11) //E置低
#define EN_SET P6OUT |= (1 << P11) //E置高
#define PSB_CLR P6OUT &= ~(1 << P12) //PSB置低,串口方式
#define PSB_SET P6OUT |= (1 << P12) //PSB置高,并口方式
#define RST_CLR P6OUT &= ~(1 << P13) //RST置低
#define RST_SET P6OUT |= (1 << P13) //RST置高
#define DataPort P3OUT //P4口為數(shù)據(jù)口
uint16_t freq = 0;
uint8_t printflag = 0;
uchar lcd_buf[6]={0,0,0,0,0,0};
char a1 = 0;
void WDT_Init()
{
WDTCTL = WDTPW + WDTHOLD; //關閉看門狗
}
//*************************************************************************
// 初始化IO口子程序
//*************************************************************************
void Port_init()
{
P3SEL = 0x00;
P3DIR = 0xFF;
P6SEL = 0x00;
P6DIR|= BIT0 + BIT1 + BIT2 + BIT3 + BIT4;
PSB_SET; //液晶并口方式
RST_SET; //復位腳RST置高
}
//***********************************************************************
// 顯示屏命令寫入函數(shù)
//***********************************************************************
void LCD_write_com(unsigned char com)
{
RS_CLR;
RW_CLR;
EN_SET;
DataPort = com;
delay_ms(5);
EN_CLR;
}
//***********************************************************************
// 顯示屏數(shù)據(jù)寫入函數(shù)
//***********************************************************************
void LCD_write_data(unsigned char data)
{
RS_SET;
RW_CLR;
EN_SET;
DataPort = data;
delay_ms(5);
EN_CLR;
}
//***********************************************************************
// 顯示屏清空顯示
//***********************************************************************
void LCD_clear(void)
{
LCD_write_com(0x01);
delay_ms(5);
}
//***********************************************************************
// 顯示屏字符串寫入函數(shù)
//***********************************************************************
void LCD_write_str(unsigned char x,unsigned char y,unsigned char *s)
{
if (y == 0)
{
LCD_write_com(0x83 + x); //第一行顯示
}
if(y == 1)
{
LCD_write_com(0x90 + x); //第二行顯示
}
if (y == 2)
{
LCD_write_com(0x88 + x); //第三行顯示
}
if(y == 3)
{
LCD_write_com(0x98 + x); //第四行顯示
}
delay_ms(10);
while (*s)
{
LCD_write_data( *s);
delay_ms(5);
s ++;
}
}
void LCD_init(void)
{
LCD_write_com(FUN_MODE); //顯示模式設置
delay_ms(5);
LCD_write_com(FUN_MODE); //顯示模式設置
delay_ms(5);
LCD_write_com(DISPLAY_ON); //顯示開
delay_ms(5);
LCD_write_com(CLEAR_SCREEN); //清屏
delay_ms(5);
}
作者:
l884859265
時間:
2019-4-9 13:44
顯示字符串的函數(shù)調(diào)用
void display_desk()
{
LCD_write_str(0,0,"123456");
LCD_write_str(0,1,lcd_buf);
LCD_write_str(0,2,"實際電流:");
}
作者:
l884859265
時間:
2019-4-9 13:47
然后現(xiàn)在12864上面第一行有“123456”,第三行有“實際電流”可第二行沒有顯示數(shù)組lcd_buf里的值,已經(jīng)確定數(shù)組里有值的無符號字符型,但就是顯示不出來,求大佬幫忙
作者:
l884859265
時間:
2019-4-10 22:01
已解決,原因:進入低功耗模式,沒有出來,去掉低功耗就好了
作者:
笙與虒
時間:
2019-8-1 10:32
樓主的12864定義和顯示程序能發(fā)上來看看嗎 我不會用顯示屏
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1