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

2019-08-18 20:05发布

联系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);
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
5条回答
正点原子
1楼-- · 2019-08-19 02:02
帮顶。。。。
ytmkkk1986
2楼-- · 2019-08-19 06:27

谢谢原子哥帮顶.

 谁有空帮确认下现在程序对与不对就?我自认为程序应该不会错,示波器我也抓来看了波形,没数据出来。芯片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.


谢谢各位大神关注!

豹影显示
3楼-- · 2019-08-19 12:10
 精彩回答 2  元偷偷看……
小融
4楼-- · 2019-08-19 15:46
本帖最后由 小融 于 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在高阻态。我看你程序没有
慢慢炖
5楼-- · 2019-08-19 19:45
ytmkkk1986 发表于 2015-4-12 22:03
**** 作者被禁止或删除 内容自动屏蔽 ****

谢谢你的PDF

一周热门 更多>