crystal_lattice
Joined: 13 Jun 2006 Posts: 164
|
DS1904 reset problem |
Posted: Mon Dec 03, 2007 12:00 am |
|
|
Hi all.
I got my DS1904 working but came across a bit of a uncertainty.
According to the flow chart in the datasheet (pg5) it states that in order to update the actual RTC counter with the R/W buffer a reset pulse is equired. I added a "touch_reset()" function to the CCS touch driver and this works.
On the next page it states that when reading the clock register (Read Clock (0x66)) it can be stopped at any time by issueing a reset pulse. It works except that it causes all other comms to stop. if i do a "get_status()" which only reads clock control byte, any subsequent reads fail. If i leave it out every thing works.
Am i missing something vital or is my reset sequence not right?
I know the function Get_time() reads the control reg but i would like to have a function that only reads the clock control reg.
Kind Regards
Code: |
void Set_Time(unsigned int32 Time)
{
touch_write_byte(0x99); //Write Clock register command
touch_write_byte(0x0C); //Set osc to run
touch_write_byte(MAKE8(time, 0)); //LSB
touch_write_byte(MAKE8(time, 1));
touch_write_byte(MAKE8(time, 2));
touch_write_byte(MAKE8(time, 3)); //MSB
touch_reset(); //Transfer data from R/W buffer to register
}
unsigned int32 Get_Time()
{
int8 control_reg;
int8 TimeLSB, Time2, Time3, TimeMSB;
touch_write_byte(0x66); //Read Clock register command
control_reg = touch_read_byte(); //Read control register
TimeLSB = touch_read_byte(); //LSB
Time2 = touch_read_byte();
Time3 = touch_read_byte();
TimeMSB = touch_read_byte(); //MSB
touch_reset(); //According to datasheet flow chart it is needed
return(make32(TimeMSB, Time3, Time2, TimeLSB));
}
int8 Get_Status()
{
int8 control_reg;
touch_write_byte(0x66); //Read Clock register
control_reg = touch_read_byte(); //Read control register
touch_reset(); //Stop reading
return(control_reg);
}
void touch_reset()
{
output_low(TOUCH_PIN);
delay_us(500);
output_float(TOUCH_PIN);
} |
|
|