专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
proteus
PROTEUS上硬件连接如图,该段程序在51上测试能实现刷屏功能,移植到ARM后则驱动不了,时序也有问题,请问如何解决?
2019-07-18 08:38
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
proteus
7423
9
1771
proteus
上硬件连接如图,该段程序在51上测试能实现刷屏功能,移植到
ARM
后则驱动不了,时序也有问题。
友情提示:
此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
9条回答
尘埃落定Z
1楼-- · 2019-07-18 13:18
/********************************************************************************************************
- FB-EDU-PARM-LPC2138 User Function file
-
- Author: yelx
-
- Date: 2018-06-04
-
- Guangzhou Windway
********************************************************************************************************/
/****************************************************************************
* 文件名:LCDTEST.C
* 功能:显示图像,显示汉字,显示字符
****************************************************************************/
#include "Config.h"
#include "Target.h"
#include "iolpc2134.h"
#define RED 0XF800
#define GREEN 0X07E0
#define BLUE 0X001F
#define WHITE 0XFFFF
#define LCD_MOSI (1<<6)
#define LCD_MISO (1<<5)
#define cs (1<<2)
#define sck (1<<4)
#define dc (1<<3)
#define rst (1<<1)
/*---------------延时子程序----------------*/
void delay (uint16 us)
{
while(us--);
}
void delay_ms (uint16 ms)
{
uint16 i,j;
for(i=0;i<ms;i++)
for(j=0;j<3000;j++)
;
}
/*
unsigned char qufan(unsigned char k)
{
unsigned char a,b,c,d,e,f,g,h;
a=k&0x01;a<<7;
b=k&0x02;b<<5;
c=k&0x04;c<<3;
d=k&0x08;d<<1;
e=k&0x10;e>>1;
f=k&0x20;f>>3;
g=k&0x40;g>>5;
h=k&0x80;h>>7;
k=(((((((a|b)|c)|d)|e)|f)|g)|h);
return k;
}
*/
unsigned char SPI_RW(unsigned char byte)
{
unsigned char bit_ctr;
for(bit_ctr=0;bit_ctr<8;bit_ctr++)
{
IO0CLR=sck;
//qufan(byte);
IO0PIN=(IO0PIN&0XFFFFFFFE|byte);
byte=(byte<<1);
IO0SET=sck;
byte|=LCD_MISO;
}
return byte;
}
void LCD_CD_DATA(unsigned char val)
{
IO0CLR=cs;
IO0SET=dc;
SPI_RW(val);
IO0SET=cs;
}
void LCD_CD_REG(unsigned char reg)
{
IO0CLR=cs;
IO0CLR=dc;
SPI_RW(reg);
IO0SET=cs;
}
void LCD_Init()
{
IO0CLR=rst;
delay_ms(50);
IO0SET=rst;
delay_ms(120);
LCD_CD_REG(0xCF);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0xC1);
LCD_CD_DATA(0X30);
LCD_CD_REG(0xED);
LCD_CD_DATA(0x64);
LCD_CD_DATA(0x03);
LCD_CD_DATA(0X12);
LCD_CD_DATA(0X81);
LCD_CD_REG(0xE8);
LCD_CD_DATA(0x85);
LCD_CD_DATA(0x10);
LCD_CD_DATA(0x7A);
LCD_CD_REG(0xCB);
LCD_CD_DATA(0x39);
LCD_CD_DATA(0x2C);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x34);
LCD_CD_DATA(0x02);
LCD_CD_REG(0xF7);
LCD_CD_DATA(0x20);
LCD_CD_REG(0xEA);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x00);
LCD_CD_REG(0xC0); //Power control
LCD_CD_DATA(0x1B); //VRH[5:0]
LCD_CD_REG(0xC1); //Power control
LCD_CD_DATA(0x01); //SAP[2:0];BT[3:0]
LCD_CD_REG(0xC5); //VCM control
LCD_CD_DATA(0x30); //3F
LCD_CD_DATA(0x30); //3C
LCD_CD_REG(0xC7); //VCM control2
LCD_CD_DATA(0XB7);
LCD_CD_REG(0x36); // Memory Access Control
LCD_CD_DATA(0x48);
LCD_CD_REG(0x3A);
LCD_CD_DATA(0x55);
LCD_CD_REG(0xB1);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x1A);
LCD_CD_REG(0xB6); // Display Function Control
LCD_CD_DATA(0x0A);
LCD_CD_DATA(0xA2);
LCD_CD_REG(0xF2); // 3Gamma Function Disable
LCD_CD_DATA(0x00);
LCD_CD_REG(0x26); //Gamma curve selected
LCD_CD_DATA(0x01);
LCD_CD_REG(0xE0); //Set Gamma
LCD_CD_DATA(0x0F);
LCD_CD_DATA(0x2A);
LCD_CD_DATA(0x28);
LCD_CD_DATA(0x08);
LCD_CD_DATA(0x0E);
LCD_CD_DATA(0x08);
LCD_CD_DATA(0x54);
LCD_CD_DATA(0XA9);
LCD_CD_DATA(0x43);
LCD_CD_DATA(0x0A);
LCD_CD_DATA(0x0F);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x00);
LCD_CD_REG(0XE1); //Set Gamma
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x15);
LCD_CD_DATA(0x17);
LCD_CD_DATA(0x07);
LCD_CD_DATA(0x11);
LCD_CD_DATA(0x06);
LCD_CD_DATA(0x2B);
LCD_CD_DATA(0x56);
LCD_CD_DATA(0x3C);
LCD_CD_DATA(0x05);
LCD_CD_DATA(0x10);
LCD_CD_DATA(0x0F);
LCD_CD_DATA(0x3F);
LCD_CD_DATA(0x3F);
LCD_CD_DATA(0x0F);
LCD_CD_REG(0x2B);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x01);
LCD_CD_DATA(0x3f);
LCD_CD_REG(0x2A);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0xef);
LCD_CD_REG(0x11); //Exit Sleep
delay_ms(120);
LCD_CD_REG(0x29); //display on
}
void LCD_SetArea(unsigned int stx,unsigned int sty,unsigned int endx,unsigned int endy)
{
LCD_CD_REG(0x2A);
LCD_CD_DATA(stx>>8);
LCD_CD_DATA(stx&0xff);
LCD_CD_DATA(endx>>8);
LCD_CD_DATA(endx&0xff);
LCD_CD_REG(0x2B);
LCD_CD_DATA(sty>>8);
LCD_CD_DATA(sty&0xff);
LCD_CD_DATA(endy>>8);
LCD_CD_DATA(endy&0xff);
}
void LcdWirteColorData(unsigned int color)
{
IO0CLR=cs;
IO0SET=dc;
SPI_RW(color>>8);
SPI_RW(color);
IO0SET=cs;
}
void LCD_Clear(unsigned int color)
{
unsigned int i,j;
LCD_SetArea(0,0,239,319);
LCD_CD_REG(0x2C);
for(i=0;i<320;i++)
{
for(j=0;j<240;j++)
{
LcdWirteColorData(color);
}
}
}
void main()
{
TargetResetInit();
PINSEL0 = 0x00000000; // 设置PIN0为GPIO
PINSEL1 = 0x00000000; // 设置PIN1为GPIO
IO0DIR = 0xfffffffF;
delay_ms(100);
//spi_init();
LCD_Init();
while(1)
{
LCD_Clear(RED);
delay_ms(300);
LCD_Clear(BLUE);
delay_ms(300);
LCD_Clear(GREEN);
delay_ms(300);
}
}
加载中...
尘埃落定Z
2楼-- · 2019-07-18 13:52
怀疑是数据输出上出问题i
加载中...
chenwei6991627
3楼-- · 2019-07-18 17:06
精彩回答 2 元偷偷看……
加载中...
尘埃落定Z
4楼-- · 2019-07-18 22:19
chenwei6991627 发表于 2018-7-10 19:22
具体什么问题呢?
像截图上的,SPI的MOSI口没有数据输出,在51上是没问题的
加载中...
尘埃落定Z
5楼-- · 2019-07-18 22:53
换SPI数据寄存器将数据发送到总线上实现了正常的时序
加载中...
尘埃落定Z
6楼-- · 2019-07-19 01:48
目前时序正常但是显示屏黑屏,目测初始化程序有问题
加载中...
1
2
下一页
一周热门
更多
>
相关问题
STM32F4上I2C(在PROTEUS中模拟)调试不通的问题
6 个回答
为什么Proteus 仿真点阵字体缺笔画 而且速度奇慢
7 个回答
2012~~单片机C语言程序设计实训100例-基于8051+Proteus仿真(第2版)
27 个回答
新手求帮忙解决proteus的问题
1 个回答
大家好,请问用三菱plc仿真软件跟mcgs组态软件怎么样连接?
1 个回答
proteus出问题,不能用
3 个回答
数字频率计 求编程(汇编或C语言)
1 个回答
求单片机与PC机串行通信
2 个回答
相关文章
×
关闭
采纳回答
向帮助了您的网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
proteus
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
关闭
您已邀请
15
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
- FB-EDU-PARM-LPC2138 User Function file
-
- Author: yelx
-
- Date: 2018-06-04
-
- Guangzhou Windway
********************************************************************************************************/
/****************************************************************************
* 文件名:LCDTEST.C
* 功能:显示图像,显示汉字,显示字符
****************************************************************************/
#include "Config.h"
#include "Target.h"
#include "iolpc2134.h"
#define RED 0XF800
#define GREEN 0X07E0
#define BLUE 0X001F
#define WHITE 0XFFFF
#define LCD_MOSI (1<<6)
#define LCD_MISO (1<<5)
#define cs (1<<2)
#define sck (1<<4)
#define dc (1<<3)
#define rst (1<<1)
/*---------------延时子程序----------------*/
void delay (uint16 us)
{
while(us--);
}
void delay_ms (uint16 ms)
{
uint16 i,j;
for(i=0;i<ms;i++)
for(j=0;j<3000;j++)
;
}
/*
unsigned char qufan(unsigned char k)
{
unsigned char a,b,c,d,e,f,g,h;
a=k&0x01;a<<7;
b=k&0x02;b<<5;
c=k&0x04;c<<3;
d=k&0x08;d<<1;
e=k&0x10;e>>1;
f=k&0x20;f>>3;
g=k&0x40;g>>5;
h=k&0x80;h>>7;
k=(((((((a|b)|c)|d)|e)|f)|g)|h);
return k;
}
*/
unsigned char SPI_RW(unsigned char byte)
{
unsigned char bit_ctr;
for(bit_ctr=0;bit_ctr<8;bit_ctr++)
{
IO0CLR=sck;
//qufan(byte);
IO0PIN=(IO0PIN&0XFFFFFFFE|byte);
byte=(byte<<1);
IO0SET=sck;
byte|=LCD_MISO;
}
return byte;
}
void LCD_CD_DATA(unsigned char val)
{
IO0CLR=cs;
IO0SET=dc;
SPI_RW(val);
IO0SET=cs;
}
void LCD_CD_REG(unsigned char reg)
{
IO0CLR=cs;
IO0CLR=dc;
SPI_RW(reg);
IO0SET=cs;
}
void LCD_Init()
{
IO0CLR=rst;
delay_ms(50);
IO0SET=rst;
delay_ms(120);
LCD_CD_REG(0xCF);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0xC1);
LCD_CD_DATA(0X30);
LCD_CD_REG(0xED);
LCD_CD_DATA(0x64);
LCD_CD_DATA(0x03);
LCD_CD_DATA(0X12);
LCD_CD_DATA(0X81);
LCD_CD_REG(0xE8);
LCD_CD_DATA(0x85);
LCD_CD_DATA(0x10);
LCD_CD_DATA(0x7A);
LCD_CD_REG(0xCB);
LCD_CD_DATA(0x39);
LCD_CD_DATA(0x2C);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x34);
LCD_CD_DATA(0x02);
LCD_CD_REG(0xF7);
LCD_CD_DATA(0x20);
LCD_CD_REG(0xEA);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x00);
LCD_CD_REG(0xC0); //Power control
LCD_CD_DATA(0x1B); //VRH[5:0]
LCD_CD_REG(0xC1); //Power control
LCD_CD_DATA(0x01); //SAP[2:0];BT[3:0]
LCD_CD_REG(0xC5); //VCM control
LCD_CD_DATA(0x30); //3F
LCD_CD_DATA(0x30); //3C
LCD_CD_REG(0xC7); //VCM control2
LCD_CD_DATA(0XB7);
LCD_CD_REG(0x36); // Memory Access Control
LCD_CD_DATA(0x48);
LCD_CD_REG(0x3A);
LCD_CD_DATA(0x55);
LCD_CD_REG(0xB1);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x1A);
LCD_CD_REG(0xB6); // Display Function Control
LCD_CD_DATA(0x0A);
LCD_CD_DATA(0xA2);
LCD_CD_REG(0xF2); // 3Gamma Function Disable
LCD_CD_DATA(0x00);
LCD_CD_REG(0x26); //Gamma curve selected
LCD_CD_DATA(0x01);
LCD_CD_REG(0xE0); //Set Gamma
LCD_CD_DATA(0x0F);
LCD_CD_DATA(0x2A);
LCD_CD_DATA(0x28);
LCD_CD_DATA(0x08);
LCD_CD_DATA(0x0E);
LCD_CD_DATA(0x08);
LCD_CD_DATA(0x54);
LCD_CD_DATA(0XA9);
LCD_CD_DATA(0x43);
LCD_CD_DATA(0x0A);
LCD_CD_DATA(0x0F);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x00);
LCD_CD_REG(0XE1); //Set Gamma
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x15);
LCD_CD_DATA(0x17);
LCD_CD_DATA(0x07);
LCD_CD_DATA(0x11);
LCD_CD_DATA(0x06);
LCD_CD_DATA(0x2B);
LCD_CD_DATA(0x56);
LCD_CD_DATA(0x3C);
LCD_CD_DATA(0x05);
LCD_CD_DATA(0x10);
LCD_CD_DATA(0x0F);
LCD_CD_DATA(0x3F);
LCD_CD_DATA(0x3F);
LCD_CD_DATA(0x0F);
LCD_CD_REG(0x2B);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x01);
LCD_CD_DATA(0x3f);
LCD_CD_REG(0x2A);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0x00);
LCD_CD_DATA(0xef);
LCD_CD_REG(0x11); //Exit Sleep
delay_ms(120);
LCD_CD_REG(0x29); //display on
}
void LCD_SetArea(unsigned int stx,unsigned int sty,unsigned int endx,unsigned int endy)
{
LCD_CD_REG(0x2A);
LCD_CD_DATA(stx>>8);
LCD_CD_DATA(stx&0xff);
LCD_CD_DATA(endx>>8);
LCD_CD_DATA(endx&0xff);
LCD_CD_REG(0x2B);
LCD_CD_DATA(sty>>8);
LCD_CD_DATA(sty&0xff);
LCD_CD_DATA(endy>>8);
LCD_CD_DATA(endy&0xff);
}
void LcdWirteColorData(unsigned int color)
{
IO0CLR=cs;
IO0SET=dc;
SPI_RW(color>>8);
SPI_RW(color);
IO0SET=cs;
}
void LCD_Clear(unsigned int color)
{
unsigned int i,j;
LCD_SetArea(0,0,239,319);
LCD_CD_REG(0x2C);
for(i=0;i<320;i++)
{
for(j=0;j<240;j++)
{
LcdWirteColorData(color);
}
}
}
void main()
{
TargetResetInit();
PINSEL0 = 0x00000000; // 设置PIN0为GPIO
PINSEL1 = 0x00000000; // 设置PIN1为GPIO
IO0DIR = 0xfffffffF;
delay_ms(100);
//spi_init();
LCD_Init();
while(1)
{
LCD_Clear(RED);
delay_ms(300);
LCD_Clear(BLUE);
delay_ms(300);
LCD_Clear(GREEN);
delay_ms(300);
}
}
像截图上的,SPI的MOSI口没有数据输出,在51上是没问题的
一周热门 更多>