打印

香主,求教FSMC总线液晶连接问题!!

[复制链接]
2513|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
su27meng|  楼主 | 2011-12-9 13:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 su27meng 于 2011-12-9 13:53 编辑

芯片型号STM32F103ZET6,液晶驱动芯片为ILI9340, 液晶片选NE1(PD7管脚),液晶RS(A19)PE3管脚。数据宽度为16位。下面的代码为FSMC IO口初始化代码和FSMC初始化代码。出现的问题,通过示波器测量发现,循环的发送命令数据时,RS管脚并没有出现规律的高低电平变化,反而是一直维持在一个不高不低的水平(未知状态)。希望大侠们帮小弟看一下,下面的代码是否有问题。不胜感激。

static uint16_t *lcd_addr = (uint16_t *)(((uint32_t)0x60000000));

static uint16_t *LcdCmd = (uint16_t *)(0x60000000);

static uint16_t *LcdData = (uint16_t *)(0x60000000 | 0x00100000);

void LCD_WriteCmd(uint8_t cmd){

*LcdCmd = cmd;


delay(10);

}



void LCD_WriteData(uint8_t data){

*LcdData = data;

}



void LCD_GPIO_Init(){

GPIO_InitTypeDef GPIO_InitStructure;

      
/*
使能 FSMC, GPIOD, GPIOE, GPIOF, GPIOG AFIO 时钟 */


RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);

      
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE |


RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG |
RCC_APB2Periph_AFIO, ENABLE);   

/*
设置 PD.00(D2), PD.01(D3), PD.04(NOE), PD.05(NWE), PD.08(D13), PD.09(D14),
PD.10(D15), PD.14(D0), PD.15(D1) 为复用推挽输出 */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5 |


GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_14 | GPIO_Pin_15;


GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;


GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;


GPIO_Init(GPIOD, &GPIO_InitStructure);
      

/*
设置 PE.07(D4), PE.08(D5), PE.09(D6), PE.10(D7), PE.11(D8), PE.12(D9), PE.13(D10),


PE.14(D11), PE.15(D12)
为复用推挽输出 */


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);

      
/*
设置 PE.03(A19 (RS))为复用推挽输出 */


GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;


GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;


GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;


GPIO_Init(GPIOE, &GPIO_InitStructure);


/*
设置 PD.07(NE1 (LCD/CS)) 为复用推挽输出 - CE3(LCD /CS) */


GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;


GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;


GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;


GPIO_Init(GPIOD, &GPIO_InitStructure);


GPIO_LCD_BackLight_Init();
}



static void GPIO_LCD_BackLight_Init(void){

GPIO_InitTypeDef GPIO_InitStructure;


RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);


GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;


GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;


GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;


GPIO_Init(GPIOB, &GPIO_InitStructure);


GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;


GPIO_Init(GPIOF, &GPIO_InitStructure);

}

/*

* Funciton Name: LCDE_FSMC_Config


* Function fuction:
配置LCDFSMC并口访问时序


*/


void LCD_FSMC_Config(void){

FSMC_NORSRAMInitTypeDef
FSMC_NORSRAMInitStructure;


FSMC_NORSRAMTimingInitTypeDef
FSMC_NORSRAMTimingInitStructure;

      
/*-- FSMC Configuration ------------------------------------------------------*/


/*----------------------- SRAM Bank 4 ----------------------------------------*/


/* FSMC_Bank1_NORSRAM4 configuration */


FSMC_NORSRAMTimingInitStructure.FSMC_AddressSetupTime = 0;


FSMC_NORSRAMTimingInitStructure.FSMC_AddressHoldTime = 1;


FSMC_NORSRAMTimingInitStructure.FSMC_DataSetupTime = 1;


FSMC_NORSRAMTimingInitStructure.FSMC_BusTurnAroundDuration = 0;


FSMC_NORSRAMTimingInitStructure.FSMC_CLKDivision = 0;


FSMC_NORSRAMTimingInitStructure.FSMC_DataLatency = 1;


FSMC_NORSRAMTimingInitStructure.FSMC_AccessMode = FSMC_AccessMode_A;


//code from armfly


/* Color LCD configuration ------------------------------------


LCD configured as follow:


- Data/Address MUX = Disable


- Memory Type = SRAM


- Data Width = 16bit


- Write Operation = Enable


- Extended Mode = Enable


- Asynchronous Wait = Disable */


FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;


FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;


FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;


FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;


FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;


//code from armfly

FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_High;

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 = &FSMC_NORSRAMTimingInitStructure;


FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &FSMC_NORSRAMTimingInitStructure;

      
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);

      
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);

}
沙发
weibestww| | 2011-12-17 22:25 | 只看该作者
好长的代码;P,有谁会去看

使用特权

评论回复
板凳
qhuang| | 2011-12-19 15:49 | 只看该作者
不应该是
   static uint16_t *LcdData = (uint16_t *)(0x60000000 | 0x00100000);
而应该是
static uint16_t *LcdData = (uint16_t *)(0x60000000 | 0x00080000);

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

5

帖子

0

粉丝