SPI-->DS1302 ???

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
docn_292601
Level 2
Level 2
10 replies posted 10 sign-ins 5 replies posted

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
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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