OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 7841|回复: 5

TFT屏 NT35510 三线SPI读ID程序,有没有人会写?用过能读出ID的?搞了好多天没搞好,

[复制链接]

1

主题

3

帖子

0

精华

新手上路

积分
32
金钱
32
注册时间
2015-4-10
在线时间
1 小时
发表于 2015-4-10 15:38:59 | 显示全部楼层 |阅读模式
5金钱
联系QQ1033972671
我使终读不对,搞了好多天了。资料都看了好多次了。

 unsigned char LCD_ReadData()   //LCDVF0=CS; LCDVF1=SDI; LCDVF2=SCK
{
 #if 1       //16-bit Serial Interface SCL????????·???????
 unsigned short i,MB=0X40;
 unsigned char data =0;
 SPI_Start();
 i = data;
  MB=0Xc0;
 for(i=0;i<8;i++)
   {
    SCLK(0); 
    Delayus(100);
     if(MB&0x80)
    SDI(1);   
     else
    SDI(0);
    Delayus(100);
    SCLK(1);
    Delayus(100);   
     MB<<=1;
   }
  Delayus(100); 
  SetSDItoIN();
  Delayus(100); 
 for(i=0;i<8;i++)
   {
    SCLK(0); 
     Delayus(100);
    Delayus(100);
    SCLK(1);
     Delayus(100);
    data <<=1;
    if(CheckSDI()){
     data++;
    }   
        Delayus(100);     
   }
       
  Delayus(100); 
    SPI_Stop();
  return data;
 #endif
}

unsigned short ID[3];
void NT35512_Read_ID(void)
{

 LCD_REG(0XDA00);
 ID[0] = LCD_ReadData();
 LCD_REG(0XDB00);
 ID[1] = LCD_ReadData();
 LCD_REG(0XDC00);
 ID[2] = LCD_ReadData();
}

上升沿发送数据。以上为我的读程序,我的写程序对屏初始化都正常,请问读程序哪里有问题?

 

void SPI_Start(void)
{
 SetSDItoOUT();
  SCLK(1); 
 Delayus(100);
 CS(1);
 Delayus(100);
  CS(0);
 Delayus(50);
 SCLK(0);
}

void SPI_Stop(void)
{
 SCLK(1);
 Delayus(50);
  CS(1);
 Delayus(100);
}

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165540
金钱
165540
注册时间
2010-12-1
在线时间
2117 小时
发表于 2015-4-10 19:06:08 | 显示全部楼层
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复

使用道具 举报

1

主题

3

帖子

0

精华

新手上路

积分
32
金钱
32
注册时间
2015-4-10
在线时间
1 小时
 楼主| 发表于 2015-4-12 22:03:18 | 显示全部楼层

谢谢原子哥帮顶.

 谁有空帮确认下现在程序对与不对就?我自认为程序应该不会错,示波器我也抓来看了波形,没数据出来。芯片IO口我看了多次,NXP M3的,除了没高阻态悬浮态。我把接收IO设成输入态准备接收数据时,示波器的显示会随最后输出态而定,即最后输出为高,就为高,最后输出为低就为低。

上面贴的图片自己看不到,所以又贴了一个。 主要读操作在PDF 49页。

主要根据下面的意思写的读程序,图片可能看不到,就贴先字了:

5.1.3 SerialInterface
The selection of this interface is done by IM3, IM2, IM1 and IM0.
The serial interface can select IM3= 0 or 1 to decide the trigger edge of serial clock (SCL) is rising edge or falling
edge. The serial  interface is used to communication  between  the  micro  controller  and  the  LCD  driver  chip.  It
contains CSX(chip select), SCL (serial clock), SDI (serial data input) and SDO (serial data output). Serial clock
(SCL) is used for interface with MPU only, so it can be stopped when no communication i s necessary. If the host
places  the  SDI  line  into  high-impedance  state  during  the  read  intervals,  then  the  SDI  and  SDO  can  be  tied
together.

5.1.3.2 READ MODE
The read mode of the interface means that the micro controller reads register value from the NT35510. To do so
the  micro  controller  first  has  to  send  a  command  and  then  the  following  byte  is  transmitted  in  the  opposite
direction. After that CSX is required to go high before a new command is send ( see  Fig. 5.1.6). The  NT35510
samples the SDI (input data) at the rising edges, but shifts SDO (output data) at the falling SCL edges. Thus the
micro controller is supported to read data at therising SCL edges. After the read status command has been sent,
the SDI line must be set to tri-state no later than at the falling SCL edge of the last bit. For the memory data read,
a dummy clock cycle is needed (16 SCL clocks) to wait the memory data send out in SPI interface. But it doesn't
need any dummy clock when execute the command data read.


谢谢各位大神关注!

NT35510_Preliminary_V0.80.pdf

10.68 MB, 下载次数: 741

回复

使用道具 举报

9

主题

167

帖子

0

精华

高级会员

Rank: 4

积分
552
金钱
552
注册时间
2013-12-15
在线时间
29 小时
发表于 2016-3-9 11:57:43 | 显示全部楼层
你讲的所谓“初始化成功”是怎样确认的 ? 屏有什么表现 ?
回复

使用道具 举报

1

主题

4

帖子

0

精华

初级会员

Rank: 2

积分
168
金钱
168
注册时间
2015-11-6
在线时间
32 小时
发表于 2017-3-13 15:13:26 | 显示全部楼层
本帖最后由 小融 于 2017-3-13 15:32 编辑

After the read status command has been sent,
the SDI line must be set to tri-state no later than at the falling SCL edge of the last bit.
楼主搞成功了吗?我最近真在搞这个,这句话是说读取之前单片机的SDO(屏幕的SDI)引脚也要设置成浮空模式,引脚说明中也说读取时单片机的SDO在高阻态。我看你程序没有
回复

使用道具 举报

19

主题

58

帖子

0

精华

初级会员

Rank: 2

积分
184
金钱
184
注册时间
2016-11-3
在线时间
42 小时
发表于 2017-5-20 17:47:10 | 显示全部楼层
ytmkkk1986 发表于 2015-4-12 22:03
**** 作者被禁止或删除 内容自动屏蔽 ****

谢谢你的PDF
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-8-21 02:09

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表