Wond3rboy
Member
Hi i wanted to write code for the DS12887 with a PIC and was looking at the timing waveforms,what got me thinking was that two parameters that have upper limits on the time.
Read-Data Hold Time tDHR
Output Data Delay Time from DS or R/W tDDR
I am using a 18LF4620 with a 4MHz crystal which gives me a MC of 1us.
Here is an example code i found for this purpose written in CCS compiler,i can write the code but before doing that i wanted to ask about the delay problems...
It uses a 16MHZ cryatal with HS i-e .25us or 250ns MC.
The reference:
CCS :: View topic - ds12887 RTC
So if i just use 1us will it cause any problems?I dont think that i will have to put any nops in between.
Read-Data Hold Time tDHR
Output Data Delay Time from DS or R/W tDDR
I am using a 18LF4620 with a 4MHz crystal which gives me a MC of 1us.
Here is an example code i found for this purpose written in CCS compiler,i can write the code but before doing that i wanted to ask about the delay problems...
It uses a 16MHZ cryatal with HS i-e .25us or 250ns MC.
Code:
char read_rtc(char addr)
{
//C7=swq,6=rclr_bar,5=irq_bar,4=reset_bar,3=ds,2=rw_bar,1=as,0=cs_bar
char data;
rtc_tris=0b11100000;//set the tris of C for setting address
rtc_tris.ad=0x00; //set the tris of D for setting address
rtc =0b00011110;//set C for for setting address
rtc.ad=addr; //put address on bus
#asm nop #endasm //pause
rtc.as=0; //latch
delay_cycles(1); // pause
rtc_tris.ad=0xFF; //set the tris of D for reading data
rtc.ds=0; //release
[B] #asm nop #endasm //pause
data=rtc.ad; //read the data from the bus[/B] [B][I]tDDR[/I][/B]
rtc_tris_r(); //set the tris of B and D to ALL INPUTS
return(data);
}
The reference:
CCS :: View topic - ds12887 RTC
So if i just use 1us will it cause any problems?I dont think that i will have to put any nops in between.