CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

DS1904 reset problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
crystal_lattice



Joined: 13 Jun 2006
Posts: 164

View user's profile Send private message

DS1904 reset problem
PostPosted: Mon Dec 03, 2007 12:00 am     Reply with quote

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);
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group