专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
STM32
7寸电容屏EPM570驱动的那款写数据问题
2019-08-19 20:03
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
STM32/STM8
5322
1
1675
我用的是总线控制
NE4做片选 可以写命令 写数据 控制背景光亮度,也可以控制更改当前显示页
但刷不了屏 点数据写进去 屏内无变化 大概代码如下
友情提示:
此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
1条回答
伤心人1
2019-08-20 01:16
本帖最后由 伤心人1 于 2017-5-5 11:16 编辑
/* LCD is connected to the FSMC_Bank1_NOR/SRAM4 and NE4 is used as ship select signal */
#define LCD_REG16 (*((volatile uint16_t *)(0x6c000000))) // RS(A0)=0
#define LCD_DAT16 (*((volatile uint16_t *)(0x6c000002))) // RS(A0)=1
#define LCD_CUR_Y 0X00
#define LCD_CUR_X 0X01
#define LCD_PIXELS 0X02
#define LCD_END_X 0X03
#define LCD_PREF 0X05
#define LCD_MIRROR 0X07
void LCD_CtrlLinesConfig(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable FSMC, GPIOD, GPIOE, GPIOF, GPIOG and AFIO clocks */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE |
RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG |
RCC_APB2Periph_AFIO, ENABLE);
/* Set 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) as alternate
function push pull */
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);
/* Set 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) as alternate function push pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | 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_Pin_5 | GPIO_Pin_3 | GPIO_Pin_4;
GPIO_Init(GPIOE, &GPIO_InitStructure);
// GPIO_WriteBit(GPIOE, GPIO_Pin_6, Bit_SET);
/* Set PF.00(A0 (RS)) as alternate function push pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_Init(GPIOF, &GPIO_InitStructure);
/* Set PG.12(NE4 (LCD/CS)) as alternate function push pull - CE3(LCD /CS) */
/* PG10 (NE30 for SRAM */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_10;//|GPIO_Pin_9;
GPIO_Init(GPIOG, &GPIO_InitStructure);
//GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
//GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_8|GPIO_Pin_9;
//GPIO_Init(GPIOB, &GPIO_InitStructure);
}
/*******************************************************************************
* Function Name : LCD_FSMCConfig
* Description : Configures the Parallel interface (FSMC) for LCD(Parallel mode)
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void LCD_FSMCConfig(void)
{
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef p;
/*-- FSMC Configuration ------------------------------------------------------*/
/*----------------------- SRAM Bank 4 ----------------------------------------*/
/* FSMC_Bank1_NORSRAM4 configuration */
p.FSMC_AddressSetupTime = 0; //0
p.FSMC_AddressHoldTime = 0; //0
/* LCD 读需要设置为4,只写的话设置1即可 */
p.FSMC_DataSetupTime = 1; //1
// p.FSMC_DataSetupTime = 2;
p.FSMC_BusTurnAroundDuration = 0;
p.FSMC_CLKDivision = 0;
p.FSMC_DataLatency = 0;
p.FSMC_AccessMode = FSMC_AccessMode_A;
/* 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_NORSRAM4;
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;
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_AsynchronousWait = FSMC_AsynchronousWait_Disable;
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
/* BANK 4 (of NOR/SRAM Bank 1~4) is enabled */
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE);
}
/*******************************************************************************
* Function Name : LCD_WriteReg
* Description : Writes to the selected LCD register.
* Input : - LCD_Reg: address of the selected register.
* - LCD_RegValue: value to write to the selected register.
* Output : None
* Return : None
*******************************************************************************/
void LCD_WriteReg(u16 LCD_Reg,u16 LCD_RegValue)
{
LCD_REG16=LCD_Reg;
LCD_DAT16=LCD_RegValue;
}
/*******************************************************************************
* Function Name : LCD_ReadReg
* Description : Reads the selected LCD Register.
* Input : None
* Output : None
* Return : LCD Register Value.
*******************************************************************************/
u16 LCD_ReadReg(u16 LCD_Reg)
{
/* Write 16-bit Index (then Read Reg) */
LCD_REG16=LCD_Reg;
/* Read 16-bit Reg */
return (LCD_DAT16);
}
void LCD_WriteRAM(u16 RGB_Code)
{
/* Write 16-bit GRAM Reg */
LCD_DAT16 = RGB_Code;
}
void wr_cmd (u16 c) {
LCD_REG16 = c;
}
unsigned short rd_cmd(void)
{
return (LCD_REG16);
}
void wr_dat (u16 c) {
LCD_DAT16 = c;
}
void wr_reg (u16 reg, u16 val) {
//wr_cmd(reg);
LCD_REG16=reg;
LCD_DAT16 =val;
// wr_dat(val);
}
unsigned short rd_dat (void) {
return (LCD_DAT16); /* return value */
}
unsigned short rd_reg (u16 reg) {
LCD_REG16=reg;
return (LCD_DAT16);
}
void LCD_Clear(u16 Color)
{
u32 i;
wr_reg(LCD_CUR_Y, 0);
wr_reg(LCD_CUR_X, 0);
// wr_reg(LCD_END_X, 799); //x终点坐标为800
//wr_cmd(LCD_PIXELS);
wr_cmd(LCD_PIXELS);
for(i = 0; i < 38400/*(LCD_XSIZE*LCD_YSIZE)*/; i++)
{
// LCD_DAT16 = Color;
LCD_WriteRAM(Color);
// i++;
}
}
void LCD_init()
{
u32 i;
i=0;
/*LCD_RST 使用硬件阻容复位
LCD_RST=0;
Delay(100);
LCD_RST=1; */
/* Configure the LCD Control pins --------------------------------------------*/
LCD_CtrlLinesConfig();
/* Configure the FSMC Parallel interface -------------------------------------*/
LCD_FSMCConfig();
/*初始化寄存器*/
while(i<0X1FFF)
{
if(rd_cmd()&0x0001)break;//等待控制器准备好
i++;
}
lcddev.setxcmd=LCD_CUR_X; //设置写X坐标指令
lcddev.setycmd=LCD_CUR_Y; //设置写Y坐标指令
lcddev.wramcmd=LCD_PIXELS; //设置写入GRAM的指令
lcddev.width=800; //设置宽度
lcddev.height=480; //设置高度
wr_reg(LCD_MIRROR, 0); //设置默认扫描方向.
for(i=0;i<63;i++)
{
wr_reg(LCD_PREF, i); //显示层为0 操作层也为0
ili9320_Delay(100000);
wr_reg(LCD_MIRROR,i);
}
wr_reg(LCD_PREF, (30+512+4096));
wr_reg(LCD_MIRROR,0);
// wr_reg(LCD_CUR_Y, 0);
// wr_reg(LCD_CUR_X, 0);
// LCD_Clear(White);
/**/
wr_reg(LCD_CUR_Y, 0);
wr_reg(LCD_CUR_X, 0);
wr_cmd(LCD_PIXELS);
for(i = 0; i < 38400/*(LCD_XSIZE*LCD_YSIZE)*/; i++)
{
// wr_cmd(LCD_PIXELS);
LCD_DAT16 = Black;//White;
// LCD_WriteRAM(White);
// i++;
}
}
加载中...
一周热门
更多
>
相关问题
STM32F4上I2C(在PROTEUS中模拟)调试不通的问题
6 个回答
芯片供应紧张,准备换个MCU,MM32L系列替换STM32L系列的怎么样?
7 个回答
STM32同时使用两个串口进行数据收发时数据丢包的问题
5 个回答
STM32F103串口通信死机问题
4 个回答
STM32WLE5CC连接SX1268在LoRa模式下能与 SX1278互通吗?
2 个回答
相关文章
ST公司第一款无线低功耗单片机模块有效提高物联网设计生产效率
0个评论
如何实现对单片机寄存器的访问
0个评论
通过USB用STM32片内自带Bootloader下载程序及注意事项
0个评论
欲练此功必先自宫之STM32汇编启动,放慢是为了更好的前行
0个评论
×
关闭
采纳回答
向帮助了您的知道网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
STM32
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
×
付费偷看金额在0.1-10元之间
确定
×
关闭
您已邀请
0
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
/* LCD is connected to the FSMC_Bank1_NOR/SRAM4 and NE4 is used as ship select signal */
#define LCD_REG16 (*((volatile uint16_t *)(0x6c000000))) // RS(A0)=0
#define LCD_DAT16 (*((volatile uint16_t *)(0x6c000002))) // RS(A0)=1
#define LCD_CUR_Y 0X00
#define LCD_CUR_X 0X01
#define LCD_PIXELS 0X02
#define LCD_END_X 0X03
#define LCD_PREF 0X05
#define LCD_MIRROR 0X07
void LCD_CtrlLinesConfig(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable FSMC, GPIOD, GPIOE, GPIOF, GPIOG and AFIO clocks */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE |
RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG |
RCC_APB2Periph_AFIO, ENABLE);
/* Set 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) as alternate
function push pull */
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);
/* Set 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) as alternate function push pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | 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_Pin_5 | GPIO_Pin_3 | GPIO_Pin_4;
GPIO_Init(GPIOE, &GPIO_InitStructure);
// GPIO_WriteBit(GPIOE, GPIO_Pin_6, Bit_SET);
/* Set PF.00(A0 (RS)) as alternate function push pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_Init(GPIOF, &GPIO_InitStructure);
/* Set PG.12(NE4 (LCD/CS)) as alternate function push pull - CE3(LCD /CS) */
/* PG10 (NE30 for SRAM */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_10;//|GPIO_Pin_9;
GPIO_Init(GPIOG, &GPIO_InitStructure);
//GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
//GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_8|GPIO_Pin_9;
//GPIO_Init(GPIOB, &GPIO_InitStructure);
}
/*******************************************************************************
* Function Name : LCD_FSMCConfig
* Description : Configures the Parallel interface (FSMC) for LCD(Parallel mode)
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void LCD_FSMCConfig(void)
{
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef p;
/*-- FSMC Configuration ------------------------------------------------------*/
/*----------------------- SRAM Bank 4 ----------------------------------------*/
/* FSMC_Bank1_NORSRAM4 configuration */
p.FSMC_AddressSetupTime = 0; //0
p.FSMC_AddressHoldTime = 0; //0
/* LCD 读需要设置为4,只写的话设置1即可 */
p.FSMC_DataSetupTime = 1; //1
// p.FSMC_DataSetupTime = 2;
p.FSMC_BusTurnAroundDuration = 0;
p.FSMC_CLKDivision = 0;
p.FSMC_DataLatency = 0;
p.FSMC_AccessMode = FSMC_AccessMode_A;
/* 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_NORSRAM4;
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;
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_AsynchronousWait = FSMC_AsynchronousWait_Disable;
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
/* BANK 4 (of NOR/SRAM Bank 1~4) is enabled */
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE);
}
/*******************************************************************************
* Function Name : LCD_WriteReg
* Description : Writes to the selected LCD register.
* Input : - LCD_Reg: address of the selected register.
* - LCD_RegValue: value to write to the selected register.
* Output : None
* Return : None
*******************************************************************************/
void LCD_WriteReg(u16 LCD_Reg,u16 LCD_RegValue)
{
LCD_REG16=LCD_Reg;
LCD_DAT16=LCD_RegValue;
}
/*******************************************************************************
* Function Name : LCD_ReadReg
* Description : Reads the selected LCD Register.
* Input : None
* Output : None
* Return : LCD Register Value.
*******************************************************************************/
u16 LCD_ReadReg(u16 LCD_Reg)
{
/* Write 16-bit Index (then Read Reg) */
LCD_REG16=LCD_Reg;
/* Read 16-bit Reg */
return (LCD_DAT16);
}
void LCD_WriteRAM(u16 RGB_Code)
{
/* Write 16-bit GRAM Reg */
LCD_DAT16 = RGB_Code;
}
void wr_cmd (u16 c) {
LCD_REG16 = c;
}
unsigned short rd_cmd(void)
{
return (LCD_REG16);
}
void wr_dat (u16 c) {
LCD_DAT16 = c;
}
void wr_reg (u16 reg, u16 val) {
//wr_cmd(reg);
LCD_REG16=reg;
LCD_DAT16 =val;
// wr_dat(val);
}
unsigned short rd_dat (void) {
return (LCD_DAT16); /* return value */
}
unsigned short rd_reg (u16 reg) {
LCD_REG16=reg;
return (LCD_DAT16);
}
void LCD_Clear(u16 Color)
{
u32 i;
wr_reg(LCD_CUR_Y, 0);
wr_reg(LCD_CUR_X, 0);
// wr_reg(LCD_END_X, 799); //x终点坐标为800
//wr_cmd(LCD_PIXELS);
wr_cmd(LCD_PIXELS);
for(i = 0; i < 38400/*(LCD_XSIZE*LCD_YSIZE)*/; i++)
{
// LCD_DAT16 = Color;
LCD_WriteRAM(Color);
// i++;
}
}
void LCD_init()
{
u32 i;
i=0;
/*LCD_RST 使用硬件阻容复位
LCD_RST=0;
Delay(100);
LCD_RST=1; */
/* Configure the LCD Control pins --------------------------------------------*/
LCD_CtrlLinesConfig();
/* Configure the FSMC Parallel interface -------------------------------------*/
LCD_FSMCConfig();
/*初始化寄存器*/
while(i<0X1FFF)
{
if(rd_cmd()&0x0001)break;//等待控制器准备好
i++;
}
lcddev.setxcmd=LCD_CUR_X; //设置写X坐标指令
lcddev.setycmd=LCD_CUR_Y; //设置写Y坐标指令
lcddev.wramcmd=LCD_PIXELS; //设置写入GRAM的指令
lcddev.width=800; //设置宽度
lcddev.height=480; //设置高度
wr_reg(LCD_MIRROR, 0); //设置默认扫描方向.
for(i=0;i<63;i++)
{
wr_reg(LCD_PREF, i); //显示层为0 操作层也为0
ili9320_Delay(100000);
wr_reg(LCD_MIRROR,i);
}
wr_reg(LCD_PREF, (30+512+4096));
wr_reg(LCD_MIRROR,0);
// wr_reg(LCD_CUR_Y, 0);
// wr_reg(LCD_CUR_X, 0);
// LCD_Clear(White);
/**/
wr_reg(LCD_CUR_Y, 0);
wr_reg(LCD_CUR_X, 0);
wr_cmd(LCD_PIXELS);
for(i = 0; i < 38400/*(LCD_XSIZE*LCD_YSIZE)*/; i++)
{
// wr_cmd(LCD_PIXELS);
LCD_DAT16 = Black;//White;
// LCD_WriteRAM(White);
// i++;
}
}
一周热门 更多>