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 CCS Technical Support

How to use free ram space in ds1307

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



Joined: 23 Sep 2024
Posts: 5

View user's profile Send private message

How to use free ram space in ds1307
PostPosted: Tue Sep 24, 2024 5:45 am     Reply with quote

Hello everyone. How to use free ram space in ds1307?. Can you give a code example in css language.
_________________
Software. Hardware. Research. Learning
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Tue Sep 24, 2024 7:25 am     Reply with quote

The CCS drivers DS1302.c and DS1305.c should give you some idea.
Also, a search here for DS1307 gives a lot of info.
_________________
Google and Forum Search are some of your best tools!!!!
arge



Joined: 23 Sep 2024
Posts: 5

View user's profile Send private message

PostPosted: Tue Sep 24, 2024 9:43 am     Reply with quote

I searched but couldn't find it. If you know, could you send me a link?
_________________
Software. Hardware. Research. Learning
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Tue Sep 24, 2024 11:00 am     Reply with quote

If you have the CCS software the .c files are in the PICC/Drivers directory.
If you are not a registered user I can't provide you the files due to copyright.
Also a forum search gives a great deal of info...don't know why you can't find it.

BTW, this is CCS PICC not CSS or Code Composer so you may have the wrong forum.
_________________
Google and Forum Search are some of your best tools!!!!
arge



Joined: 23 Sep 2024
Posts: 5

View user's profile Send private message

PostPosted: Tue Sep 24, 2024 12:39 pm     Reply with quote

Code:

///////////////////// TEST CODE ////////////////////////////////////////////////////
void ds1307_REGISTER_WRITE(BYTE REG8, BYTE REG9, BYTE REG10)
{
  i2c_start();
  i2c_write(0xD0);            // I2C write address
  i2c_write(0x08);            // Start at REG 8
  i2c_write(bin2bcd(REG8));    // REG 8
  i2c_write(bin2bcd(REG9));    // REG 9
  i2c_write(bin2bcd(REG10));   // REG 10
  i2c_stop();
}


///////////////////////////////////////////////////////////////////////////////
void ds1307_REGISTER_READ(BYTE &REG8, BYTE &REG9, BYTE &REG10)
{
  i2c_start();
  i2c_write(0xD0);
  i2c_write(0x08);            // Start at REG 8
  i2c_start();
  i2c_write(0xD1);
 
  REG8 =  bcd2bin(i2c_read());
  REG9 =  bcd2bin(i2c_read());
  REG10=  bcd2bin(i2c_read());
 
  i2c_stop();

}
////////////////////////TEST CODE /////////////////////////////////////////////

_________________
Software. Hardware. Research. Learning
arge



Joined: 23 Sep 2024
Posts: 5

View user's profile Send private message

PostPosted: Tue Sep 24, 2024 4:09 pm     Reply with quote

I updated. We can save and read values ​​between 0-255.

Code:


void ds1307_REGISTER_WRITE(int16 REG8, int16 REG9, int16 REG10)
{


  i2c_start();
  i2c_write(0xD0);   // I2C write address
  i2c_write(0x08);    // Start at REG 8
 
  i2c_write(REG8);   // REG 8
  i2c_write(REG9);   // REG 9
  i2c_write(REG10);  // REG 10
 
  i2c_stop();
}



void ds1307_REGISTER_READ(int16 &REG8, int16 &REG9, int16 &REG10)
{
  i2c_start();
  i2c_write(0xD0);    // I2C write address
  i2c_write(0x08);     // Start at REG 8
  i2c_start();
  i2c_write(0xD1);
 
  REG8 = i2c_read();  // REG 8
  REG9 = i2c_read();  // REG 9
  REG10= i2c_read();  // REG 10
 
  i2c_stop();

}



_________________
Software. Hardware. Research. Learning
arge



Joined: 23 Sep 2024
Posts: 5

View user's profile Send private message

PostPosted: Tue Sep 24, 2024 6:20 pm     Reply with quote

Code:


//ds1307_REGISTER_WRITE(adress,data);
//data=ds1307_REGISTER_READ(adress);

void ds1307_REGISTER_WRITE(unsigned int16 ds1302_adres, unsigned int16 ds1302_data)
{
  i2c_start();
  i2c_write(0xD0);        // chip address
  i2c_write(ds1302_adres);// Write to this numbered register
  i2c_write(ds1302_data); // data
  i2c_stop();
  delay_ms(50);
}


BYTE ds1307_REGISTER_READ(unsigned int16 DS_address)
{
   BYTE ds1302_data;
   
   i2c_start();             
   i2c_write(0xD0);      // chip address
   i2c_write(DS_address);// read this numbered register
   i2c_start();         
   i2c_write(0xD1);     
   
   ds1302_data = i2c_read(0);
   i2c_stop();
   delay_ms(50);
   
   return(ds1302_data);
}

_________________
Software. Hardware. Research. Learning
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