請問otm8009a裡的初始化函數Lcd_Initialize指令的意思
還有為什麼是用FSMC B模式
以下是程式
#include "stm32f10x.h"
#include "Tiky_LCD.h"
/*
* 函數名:LCD_GPIO_Config
* 描述 :根據FSMC配置LCD的I/O
* 輸入 :無
* 輸出 :無
* 調用 :內部調用
*/
static void LCD_GPIO_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable the FSMC Clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
/* config lcd gpio clock base on FSMC */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE , ENABLE);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
/* config tft Reset gpio */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* config tft BL gpio 背光開關控制引腳*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 ;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* config tft data lines base on FSMC
* data lines,FSMC-D0~D15: PD 14 15 0 1,PE 7 8 9 10 11 12 13 14 15,PD 8 9 10
*/
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | GPIO_Pin_9 |
GPIO_Pin_10 | GPIO_Pin_14 | GPIO_Pin_15;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 |
GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 |
GPIO_Pin_15;
GPIO_Init(GPIOE, &GPIO_InitStructure);
/* config tft control lines base on FSMC
* PD4-FSMC_NOE
CD-RD
* PD5-FSMC_NWE
CD-WR
* PD7-FSMC_NE1
CD-CS
* PD11-FSMC_A16
CD-DC
*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 ;
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* tft control gpio init */
GPIO_SetBits(GPIOD, GPIO_Pin_13); // Reset
GPIO_SetBits(GPIOD, GPIO_Pin_4); // RD = 1
GPIO_SetBits(GPIOD, GPIO_Pin_5); // WR = 1
GPIO_SetBits(GPIOD, GPIO_Pin_11); // RS
GPIO_SetBits(GPIOD, GPIO_Pin_7); // CS = 1
GPIO_SetBits(GPIOA, GPIO_Pin_1); // BL = 1
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; //按鍵 OK
GPIO_Init(GPIOA, &GPIO_InitStructure);
// right up left down
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_1 | GPIO_Pin_5 | GPIO_Pin_6;
GPIO_Init(GPIOE, &GPIO_InitStructure);
}
/*
* 函數名:LCD_FSMC_Config
* 描述 :LCD FSMC 模式配置
* 輸入 :無
* 輸出 :無
* 調用 :內部調用
*/
static void LCD_FSMC_Config(void)
{
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef p;
p.FSMC_AddressSetupTime = 0x02; //地址建立時間
p.FSMC_AddressHoldTime = 0x00; //地址保持時間
p.FSMC_DataSetupTime = 0x05; //數據建立時間
p.FSMC_BusTurnAroundDuration = 0x00;
p.FSMC_CLKDivision = 0x00;
p.FSMC_DataLatency = 0x00;
p.FSMC_AccessMode = FSMC_AccessMode_B; // 一般使用模式B來控制LCD
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_NOR;
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
/* Enable FSMC Bank1_SRAM Bank */
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);
}
volatile void LCD_delay(char j)
{
volatile u16 i;
while(j--)
for(i=7200;i>0;i--);
}
static void LCD_Rst(void)
{
GPIO_ResetBits(GPIOD, GPIO_Pin_13);
LCD_delay(10);
GPIO_SetBits(GPIOD, GPIO_Pin_13 );
LCD_delay(10);
}
void WriteComm(u16 CMD)
{
*(__IO u16 *) (Bank1_LCD_C) = CMD;
}
void WriteData(u16 tem_data)
{
*(__IO u16 *) (Bank1_LCD_D) = tem_data;
}
/**********************************************
Lcd初始化函數
***********************************************/
void Lcd_Initialize(void)
{
LCD_GPIO_Config();
LCD_FSMC_Config();
LCD_Rst();
WriteComm(0xff00); WriteData(0x80);
WriteComm(0xff01); WriteData(0x09);
WriteComm(0xff02); WriteData(0x01);
WriteComm(0xff80); WriteData(0x80);
WriteComm(0xff81); WriteData(0x09);
WriteComm(0xff03); WriteData(0x01);
WriteComm(0xc0b4); WriteData(0x50);
WriteComm(0xC489); WriteData(0x08);
WriteComm(0xC0a3); WriteData(0x00);
WriteComm(0xC582); WriteData(0xA3);
WriteComm(0xC590); WriteData(0x96);
WriteComm(0xC591); WriteData(0x87);
WriteComm(0xD800); WriteData(0x73);
WriteComm(0xD801); WriteData(0x71);
WriteComm(0xD900); WriteData(0x6A);
LCD_delay(200);
WriteComm(0xE100); WriteData(0x09);
WriteComm(0xE101); WriteData(0x0a);
WriteComm(0xE102); WriteData(0x0e);
WriteComm(0xE103); WriteData(0x0d);
WriteComm(0xE104); WriteData(0x07);
WriteComm(0xE105); WriteData(0x18);
WriteComm(0xE106); WriteData(0x0d);
WriteComm(0xE107); WriteData(0x0d);
WriteComm(0xE108); WriteData(0x01);
WriteComm(0xE109); WriteData(0x04);
WriteComm(0xE10A); WriteData(0x05);
WriteComm(0xE10B); WriteData(0x06);
WriteComm(0xE10C); WriteData(0x0D);
WriteComm(0xE10D); WriteData(0x22);
WriteComm(0xE10E); WriteData(0x20);
WriteComm(0xE10F); WriteData(0x05);
WriteComm(0xE200); WriteData(0x09);
WriteComm(0xE201); WriteData(0x0a);
WriteComm(0xE202); WriteData(0x0e);
WriteComm(0xE203); WriteData(0x0d);
WriteComm(0xE204); WriteData(0x07);
WriteComm(0xE205); WriteData(0x18);
WriteComm(0xE206); WriteData(0x0d);
WriteComm(0xE207); WriteData(0x0d);
WriteComm(0xE208); WriteData(0x01);
WriteComm(0xE209); WriteData(0x04);
WriteComm(0xE20A); WriteData(0x05);
WriteComm(0xE20B); WriteData(0x06);
WriteComm(0xE20C); WriteData(0x0D);
WriteComm(0xE20D); WriteData(0x22);
WriteComm(0xE20E); WriteData(0x20);
WriteComm(0xE20F); WriteData(0x05);
WriteComm(0xC181); WriteData(0x66);
WriteComm(0xC1a1); WriteData(0x08);
WriteComm(0xC0a3); WriteData(0x1b);
WriteComm(0xC481); WriteData(0x83);
WriteComm(0xC592); WriteData(0x01);
WriteComm(0xC5B1); WriteData(0xA9);
WriteComm(0xCE80); WriteData(0x85);
WriteComm(0xCE81); WriteData(0x03);
WriteComm(0xCE82); WriteData(0x00);
WriteComm(0xCE83); WriteData(0x84);
WriteComm(0xCE84); WriteData(0x03);
WriteComm(0xCE85); WriteData(0x00);
WriteComm(0xCE86); WriteData(0x83);
WriteComm(0xCE87); WriteData(0x03);
WriteComm(0xCE88); WriteData(0x00);
WriteComm(0xCE89); WriteData(0x82);
WriteComm(0xCE8a); WriteData(0x03);
WriteComm(0xCE8b); WriteData(0x00);
WriteComm(0xCEa0); WriteData(0x38);
WriteComm(0xCEa1); WriteData(0x02);
WriteComm(0xCEa2); WriteData(0x03);
WriteComm(0xCEa3); WriteData(0x21);
WriteComm(0xCEa4); WriteData(0x00);
WriteComm(0xCEa5); WriteData(0x00);
WriteComm(0xCEa6); WriteData(0x00);
WriteComm(0xCEa7); WriteData(0x38);
WriteComm(0xCEa8); WriteData(0x01);
WriteComm(0xCEa9); WriteData(0x03);
WriteComm(0xCEaa); WriteData(0x22);
WriteComm(0xCEab); WriteData(0x00);
WriteComm(0xCEac); WriteData(0x00);
WriteComm(0xCEad); WriteData(0x00);
WriteComm(0xCEb0); WriteData(0x38);
WriteComm(0xCEb1); WriteData(0x00);
WriteComm(0xCEb2); WriteData(0x03);
WriteComm(0xCEb3); WriteData(0x23);
WriteComm(0xCEb4); WriteData(0x00);
WriteComm(0xCEb5); WriteData(0x00);
WriteComm(0xCEb6); WriteData(0x00);
WriteComm(0xCEb7); WriteData(0x30);
WriteComm(0xCEb8); WriteData(0x00);
WriteComm(0xCEb9); WriteData(0x03);
WriteComm(0xCEba); WriteData(0x24);
WriteComm(0xCEbb); WriteData(0x00);
WriteComm(0xCEbc); WriteData(0x00);
WriteComm(0xCEbd); WriteData(0x00);
WriteComm(0xCEc0); WriteData(0x30);
WriteComm(0xCEc1); WriteData(0x01);
WriteComm(0xCEc2); WriteData(0x03);
WriteComm(0xCEc3); WriteData(0x25);
WriteComm(0xCEc4); WriteData(0x00);
WriteComm(0xCEc5); WriteData(0x00);
WriteComm(0xCEc6); WriteData(0x00);
WriteComm(0xCEc7); WriteData(0x30);
WriteComm(0xCEc8); WriteData(0x02);
WriteComm(0xCEc9); WriteData(0x03);
WriteComm(0xCEca); WriteData(0x26);
WriteComm(0xCEcb); WriteData(0x00);
WriteComm(0xCEcc); WriteData(0x00);
WriteComm(0xCEcd); WriteData(0x00);
WriteComm(0xCEd0); WriteData(0x30);
WriteComm(0xCEd1); WriteData(0x03);
WriteComm(0xCEd2); WriteData(0x03);
WriteComm(0xCEd3); WriteData(0x27);
WriteComm(0xCEd4); WriteData(0x00);
WriteComm(0xCEd5); WriteData(0x00);
WriteComm(0xCEd6); WriteData(0x00);
WriteComm(0xCEd7); WriteData(0x30);
WriteComm(0xCEd8); WriteData(0x04);
WriteComm(0xCEd9); WriteData(0x03);
WriteComm(0xCEda); WriteData(0x28);
WriteComm(0xCEdb); WriteData(0x00);
WriteComm(0xCEdc); WriteData(0x00);
WriteComm(0xCEdd); WriteData(0x00);
WriteComm(0xCFc0); WriteData(0x00);
WriteComm(0xCFc1); WriteData(0x00);
WriteComm(0xCFc2); WriteData(0x00);
WriteComm(0xCFc3); WriteData(0x00);
WriteComm(0xCFc4); WriteData(0x00);
WriteComm(0xCFc5); WriteData(0x00);
WriteComm(0xCFc6); WriteData(0x00);
WriteComm(0xCFc7); WriteData(0x00);
WriteComm(0xCFc8); WriteData(0x00);
WriteComm(0xCFc9); WriteData(0x00);
WriteComm(0xCFd0); WriteData(0x00);
WriteComm(0xCBc0); WriteData(0x00);
WriteComm(0xCBc1); WriteData(0x00);
WriteComm(0xCBc2); WriteData(0x00);
WriteComm(0xCBc3); WriteData(0x00);
WriteComm(0xCBc4); WriteData(0x04);
WriteComm(0xCBc5); WriteData(0x04);
WriteComm(0xCBc6); WriteData(0x04);
WriteComm(0xCBc7); WriteData(0x04);
WriteComm(0xCBc8); WriteData(0x04);
WriteComm(0xCBc9); WriteData(0x04);
WriteComm(0xCBca); WriteData(0x00);
WriteComm(0xCBcb); WriteData(0x00);
WriteComm(0xCBcc); WriteData(0x00);
WriteComm(0xCBcd); WriteData(0x00);
WriteComm(0xCBce); WriteData(0x00);
WriteComm(0xCBd0); WriteData(0x00);
WriteComm(0xCBd1); WriteData(0x00);
WriteComm(0xCBd2); WriteData(0x00);
WriteComm(0xCBd3); WriteData(0x00);
WriteComm(0xCBd4); WriteData(0x00);
WriteComm(0xCBd5); WriteData(0x00);
WriteComm(0xCBd6); WriteData(0x00);
WriteComm(0xCBd7); WriteData(0x00);
WriteComm(0xCBd8); WriteData(0x00);
WriteComm(0xCBd9); WriteData(0x04);
WriteComm(0xCBda); WriteData(0x04);
WriteComm(0xCBdb); WriteData(0x04);
WriteComm(0xCBdc); WriteData(0x04);
WriteComm(0xCBdd); WriteData(0x04);
WriteComm(0xCBde); WriteData(0x04);
WriteComm(0xCBe0); WriteData(0x00);
WriteComm(0xCBe1); WriteData(0x00);
WriteComm(0xCBe2); WriteData(0x00);
WriteComm(0xCBe3); WriteData(0x00);
WriteComm(0xCBe4); WriteData(0x00);
WriteComm(0xCBe5); WriteData(0x00);
WriteComm(0xCBe6); WriteData(0x00);
WriteComm(0xCBe7); WriteData(0x00);
WriteComm(0xCBe8); WriteData(0x00);
WriteComm(0xCBe9); WriteData(0x00);
WriteComm(0xCC80); WriteData(0x00);
WriteComm(0xCC81); WriteData(0x00);
WriteComm(0xCC82); WriteData(0x00);
WriteComm(0xCC83); WriteData(0x00);
WriteComm(0xCC84); WriteData(0x0C);
WriteComm(0xCC85); WriteData(0x0A);
WriteComm(0xCC86); WriteData(0x10);
WriteComm(0xCC87); WriteData(0x0E);
WriteComm(0xCC88); WriteData(0x03);
WriteComm(0xCC89); WriteData(0x04);
WriteComm(0xCC90); WriteData(0x00);
WriteComm(0xCC91); WriteData(0x00);
WriteComm(0xCC92); WriteData(0x00);
WriteComm(0xCC93); WriteData(0x00);
WriteComm(0xCC94); WriteData(0x00);
WriteComm(0xCC95); WriteData(0x00);
WriteComm(0xCC96); WriteData(0x00);
WriteComm(0xCC97); WriteData(0x00);
WriteComm(0xCC98); WriteData(0x00);
WriteComm(0xCC99); WriteData(0x00);
WriteComm(0xCC9a); WriteData(0x00);
WriteComm(0xCC9b); WriteData(0x00);
WriteComm(0xCC9c); WriteData(0x00);
WriteComm(0xCC9d); WriteData(0x00);
WriteComm(0xCC9e); WriteData(0x0B);
WriteComm(0xCCa0); WriteData(0x09);
WriteComm(0xCCa1); WriteData(0x0F);
WriteComm(0xCCa2); WriteData(0x0D);
WriteComm(0xCCa3); WriteData(0x01);
WriteComm(0xCCa4); WriteData(0x02);
WriteComm(0xCCa5); WriteData(0x00);
WriteComm(0xCCa6); WriteData(0x00);
WriteComm(0xCCa7); WriteData(0x00);
WriteComm(0xCCa8); WriteData(0x00);
WriteComm(0xCCa9); WriteData(0x00);
WriteComm(0xCCaa); WriteData(0x00);
WriteComm(0xCCab); WriteData(0x00);
WriteComm(0xCCac); WriteData(0x00);
WriteComm(0xCCad); WriteData(0x00);
WriteComm(0xCCae); WriteData(0x00);
WriteComm(0xCCb0); WriteData(0x00);
WriteComm(0xCCb1); WriteData(0x00);
WriteComm(0xCCb2); WriteData(0x00);
WriteComm(0xCCb3); WriteData(0x00);
WriteComm(0xCCb4); WriteData(0x0D);
WriteComm(0xCCb5); WriteData(0x0F);
WriteComm(0xCCb6); WriteData(0x09);
WriteComm(0xCCb7); WriteData(0x0B);
WriteComm(0xCCb8); WriteData(0x02);
WriteComm(0xCCb9); WriteData(0x01);
WriteComm(0xCCc0); WriteData(0x00);
WriteComm(0xCCc1); WriteData(0x00);
WriteComm(0xCCc2); WriteData(0x00);
WriteComm(0xCCc3); WriteData(0x00);
WriteComm(0xCCc4); WriteData(0x00);
WriteComm(0xCCc5); WriteData(0x00);
WriteComm(0xCCc6); WriteData(0x00);
WriteComm(0xCCc7); WriteData(0x00);
WriteComm(0xCCc8); WriteData(0x00);
WriteComm(0xCCc9); WriteData(0x00);
WriteComm(0xCCca); WriteData(0x00);
WriteComm(0xCCcb); WriteData(0x00);
WriteComm(0xCCcc); WriteData(0x00);
WriteComm(0xCCcd); WriteData(0x00);
WriteComm(0xCCce); WriteData(0x0E);
WriteComm(0xCCd0); WriteData(0x10);
WriteComm(0xCCd1); WriteData(0x0A);
WriteComm(0xCCd2); WriteData(0x0C);
WriteComm(0xCCd3); WriteData(0x04); &
有需要3.97寸液晶屏(CPT3.97+OTM8009A)的朋友,可以联系我支持MCU-8/16/24BIT,可用于STM32的FSMC接口,目前数量有2500PCS,提供液晶屏的所有技术支持(初始化,CAD图纸,平台上的调试)
淘宝链接图片:https://item.taobao.com/item.htm?id=558608137119
QQ:1263857188
一周热门 更多>