cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC™ 5, 3 & 1

docn_292601
New Contributor II

config:

   

   

 

   

my test code:

   

SPIM_3_Start();
    while(1)
    {
        SPIM_3_TxEnable();                           //使能SPI发送
        SPIM_3_ClearRxBuffer();                      //清空Rx缓存
        a = SPIM_3_GetRxBufferSize();
       
        SPIM_3_WriteByte(READ_SECOND_REG);           //发送地址
        SPIM_3_TxDisable();
        while(!(SPIM_3_ReadStatus() & SPIM_3_STS_TX_FIFO_EMPTY));
        b = SPIM_3_GetRxBufferSize();
       
        //使能SPI接收
        c = SPIM_3_GetRxBufferSize();
       
        while(!(SPIM_3_ReadStatus() & SPIM_3_STS_RX_FIFO_NOT_EMPTY));
        e = SPIM_3_GetRxBufferSize();
        d = SPIM_3_ReadByte();                       //读出数据
       
        sprintf(msg,"TIME:  %d %d %d  %d %d",a,b,c,d,e);
        draw_debug(msg,0,0);
    }

   

 

   

who  can tell me that the datas i get from DS1302 always are 0xff ???

   

thank you!!!

0 Likes
1 Solution
Bob_Marlowe
Expert II

Another issue I just see:

   

Before switching from transmit to receive you check the TxStatus for FiFo empty, but you should wait for complete transmission since the pin will switch to input before the transfer is complete.

   

 

   

Bob

View solution in original post

0 Likes
9 Replies