AnsweredHot!Interfacing DS1302 with dsPIC33FJ128GP802

Page: < 12 Showing page 2 of 2
Author
qhb
Superb Member
  • Total Posts : 9204
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: online
Re: Interfacing DS1302 with dsPIC33FJ128GP802 2019/01/19 02:46:56 (permalink)
0
So, the delay at the end could be moved to the front

for(i = 0; i < 8; i++)
{
    __delay_us(1) ;//Delay 1us
    SCLK = 1 ;
    __delay_us(1) ;//Delay 1us (wait for data to settle)
    *data >>= 1 ;
    if(IN)
    *data |= 0x80 ;
    SCLK = 0 ;
}

 
#21
Esmat
New Member
  • Total Posts : 29
  • Reward points : 0
  • Joined: 2009/06/14 09:41:13
  • Location: 0
  • Status: offline
Re: Interfacing DS1302 with dsPIC33FJ128GP802 2019/01/19 14:50:16 (permalink)
0
I have tried the last suggestion by qhb, but it gives me 0. I am curious why the DS works fine when the shift stmt is at the top of the loop!!!  
#22
du00000001
Just Some Member
  • Total Posts : 2499
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: Interfacing DS1302 with dsPIC33FJ128GP802 2019/01/19 15:00:15 (permalink)
0
... why it works ...?
Seems you're violating some timing condition when it's not on top. Better to find a solution that's working irrespective of the position of the shift op: would be more robust wrt future changes.

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#23
Page: < 12 Showing page 2 of 2
Jump to:
© 2019 APG vNext Commercial Version 4.5