【FRDM-MCXN947】LCD160160显示屏测试
[复制链接]
本帖最后由 TL-LED 于 2024-12-22 14:36 编辑
测试并口方式驱动LCD160160显示屏。
一、电路图部分
使用FlexIO LCD接口的引脚,模拟并口方式。
二、配置端口
配置显示屏有关的引脚
三、显示屏接口时序图
四、程序部分
4.1、UC1698Driver.c
/**
* @File UC1698Driver.c
* @author guoweilkd
* @version V1.1.0
* @date 2018/05/09
* @brief Lcd驱动
* 本文件Lcd为UC1698
*/
#include "main.h"
const uint8_t DataToBit2[] = {0x00,0x0f,0xf0,0xff};
void lcd_delay(uint16_t dl)
{
uint16_t dd;
for(dd=0;dd<dl;dd++)
{
__NOP();
}
}
/**
*@brief 引脚初始化
*@param None
*@retval None
*/
static void LcdGpioConfig(void)
{
init_tm160160_pins();
//LCD_BLA_ON();
LCD_CS_HIGH();
}
/**
*@brief 写命令
*@param cmd 命令
*@retval None
*/
void WriteLcdCommand(uint8_t cmd)
{
LCD_RS_LOW();
LCD_RD_HIGH();
LCD_DATABUS(cmd);
lcd_delay(10);
LCD_WR_LOW();
lcd_delay(1);
LCD_WR_HIGH();
}
/**
*@brief 写数据
*@param data 数据
*@retval None
*/
void WriteLcdData(uint8_t data)
{
LCD_RS_HIGH();
LCD_RD_HIGH();
LCD_DATATOBIT((data&0x03));
lcd_delay(10);
LCD_WR_LOW();
lcd_delay(5);
LCD_WR_HIGH();
}
/**
*@brief 设置起始行
*@param row 行
*@retval None
*/
void SetLcdRow(uint8_t row)
{
WriteLcdCommand(CMD_ROWADDRH | ((row & 0xF0) >> 4));
WriteLcdCommand(CMD_ROWADDRL | (row & 0x0F));
}
/**
*@brief 设置起始列
*@param col 列地址
*@retval None
*/
void SetLcdCol(uint8_t col)
{
WriteLcdCommand(CMD_COLADDRH | ((col & 0x70) >> 4));
WriteLcdCommand(CMD_COLADDRL | (col & 0x0F));
}
/**
*@brief 开显示
*@param None
*@retval None
*/
void Uc1698OpenLcdDisplay(void)
{
LCD_CS_LOW();
WriteLcdCommand(OPEN_LCDDISPLAY);
LCD_CS_HIGH();
//LCD_BLA_ON();
}
/**
*@brief UC1698U横向写8个点的子函数
*@param Data:要显示的数据
*@retval None
*/
void Write8DotsUC1698U(uint8_t Data)
{
LCD_DATATOBIT((Data >> 6));
lcd_delay(10);
LCD_WR_LOW();
lcd_delay(5);
LCD_WR_HIGH();
LCD_DATATOBIT(((Data >> 4)&0x03));
lcd_delay(10);
LCD_WR_LOW();
lcd_delay(5);
LCD_WR_HIGH();
LCD_DATATOBIT(((Data >> 2)&0x03));
lcd_delay(10);
LCD_WR_LOW();
lcd_delay(5);
LCD_WR_HIGH();
LCD_DATATOBIT((Data & 0x03));
lcd_delay(10);
LCD_WR_LOW();
lcd_delay(5);
LCD_WR_HIGH();
}
/**
*@brief 关显示
*@param None
*@retval None
*/
void Uc1698CloseLcdDisplay(void)
{
LCD_CS_LOW();
WriteLcdCommand(CLOSE_LCDDISPLAY);
LCD_CS_HIGH();
}
/**
*@brief LCD初始化
*@param None
*@retval None
*/
void LcdInit(void)
{
LcdGpioConfig();
LCD_CS_LOW();
LCD_RES_LOW();
SysTick_Delay_ms(100);
LCD_RES_HIGH();
SysTick_Delay_ms(100);
WriteLcdCommand(0xE8|(BR&0X03));//设置偏压比1/10
WriteLcdCommand(0x28|(PC1&0X03));//内部电源DC/DC
WriteLcdCommand(0x24|(TC&0x03));//温度补偿
WriteLcdCommand(0x81);//设置电位命令
WriteLcdCommand(PM ); //值
WriteLcdCommand(0xc0|(LC_210&0X07) );
WriteLcdCommand(0xa0|(LC_43 &0X03) );
WriteLcdCommand(0xd0|(LC_5 &0X01) );
WriteLcdCommand(0xd4|(LC_76 &0X03) );
WriteLcdCommand(0x84|(LC_8 &0X01) );
WriteLcdCommand(0xc8); //设置N-line
WriteLcdCommand( NIV);
WriteLcdCommand(0xd8|(CSF&0X07) );
WriteLcdCommand(0xf4);
WriteLcdCommand(WPC0);
WriteLcdCommand(0xf6);
WriteLcdCommand(WPC1);
WriteLcdCommand(0xf5);
WriteLcdCommand(WPP0);
WriteLcdCommand(0xf7);
WriteLcdCommand(WPP1);
WriteLcdCommand(0xf8|((AC>>3)&0x01));
WriteLcdCommand(0x88| (0x07&AC));
WriteLcdCommand(0xf1);
WriteLcdCommand(CEN);
WriteLcdCommand(OPEN_LCDDISPLAY);/* 开显示 */
SysTick_Delay_ms(20);
LCD_CS_HIGH();
}
/* END */
4.2、main.c
#include "main.h"
extern void defaultFontInit(void);
int main(void)
{
uint8_t i;
lkdColour color;
CLOCK_EnableClock(kCLOCK_Gpio0);
BOARD_InitDEBUG_UARTPins();
BOARD_PowerMode_OD();
BOARD_InitBootClocks();
BOARD_InitDebugConsole();
SysTick_Init();
init_led();
init_key();
LcdInit();
defaultFontInit();
GuiUpdateDisplayAll();
color = GuiGetForecolor();
GuiRowText(0, 2,160, FONT_MID,"AI FRDM-MCXN947 Board");
GuiHPointLine(0, 15, 160, 2, color);
GuiRowText(0, 60,160, FONT_MID,"https://bbs.eeworld.com.cn");
GuiRowText(0, 80,160, FONT_MID,"https://www.nxp.com.cn");
GuiRowText(0, 100,160, FONT_MID,"ID:TLLED");
GuiUpdateDisplayAll();
while (1)
{
SysTick_Delay_ms(500);
led_red_tog();
GuiRowText(0, 2,160, FONT_MID,"TTTTTTTTTTTTTTTTTTTTT");
GuiHPointLine(0, 15, 160, 2, color);
GuiRowText(0, 60,160, FONT_MID,"https://bbs.eeworld.com.cn");
GuiRowText(0, 80,160, FONT_MID,"https://www.nxp.com.cn");
GuiRowText(0, 100,160, FONT_MID,"ID:TLLED");
GuiUpdateDisplayAll();
SysTick_Delay_ms(500);
GuiRowText(0, 2,160, FONT_MID,"AI FRDM-MCXN947 Board");
GuiHPointLine(0, 15, 160, 2, color);
GuiRowText(0, 60,160, FONT_MID,"https://bbs.eeworld.com.cn");
GuiRowText(0, 80,160, FONT_MID,"https://www.nxp.com.cn");
GuiRowText(0, 100,160, FONT_MID,"ID:TLLED");
GuiUpdateDisplayAll();
}
}
4.3、程序源码
五、程序运行
下载程序后,显示屏显示如下
lcd160160
|