View previous topic :: View next topic |
Author |
Message |
arge
Joined: 23 Sep 2024 Posts: 5
|
How to use free ram space in ds1307 |
Posted: Tue Sep 24, 2024 5:45 am |
|
|
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: 1933 Location: Norman, OK
|
|
Posted: Tue Sep 24, 2024 7:25 am |
|
|
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
|
|
Posted: Tue Sep 24, 2024 9:43 am |
|
|
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: 1933 Location: Norman, OK
|
|
Posted: Tue Sep 24, 2024 11:00 am |
|
|
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
|
|
Posted: Tue Sep 24, 2024 12:39 pm |
|
|
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 ®8, BYTE ®9, BYTE ®10)
{
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
|
|
Posted: Tue Sep 24, 2024 4:09 pm |
|
|
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 ®8, int16 ®9, int16 ®10)
{
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
|
|
Posted: Tue Sep 24, 2024 6:20 pm |
|
|
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 |
|
|
|