I was unsuccessful - so tried the DS3231 component uploaded by Jordy and got thing pretty much working as I wished - including an interrupt to wake the Arduino from sleep mode. (Though not all plain sailing - see attachment for details)
I then returned to the 'official' RTC component.
First problem - the i2c address for the clock chip should be writable.
Next - setting the address to that of my RTC (0x57) gave no result.
Looking at the C generated for example for SetYear:
Code: Select all
void FCD_0a3a1_RTC1__SetYear(MX_UINT8 FCL_YEAR)
{
//Local variable definitions
MX_UINT8 FCL_DATA;
if (FCL_YEAR < 100)
{
#if (0)
//Code has been optimised out by the pre-processor
#else
#if (0) // 2 == 0
//Code has been optimised out by the pre-processor
#else
#if (1) // 2 == 1 || 2 == 2
FCL_DATA = FCL_YEAR % 10;
FCL_DATA = FCL_DATA + ((FCL_YEAR / 10) << 4);
//Comment:
//DS1307 & DS3231
FC_CAL_I2C_Master_Start_1();
FC_CAL_I2C_Master_TxByte_1(0x57); ***** i2c write start *****
FC_CAL_I2C_Master_TxByte_1(6);
FC_CAL_I2C_Master_TxByte_1(FCL_DATA);
FC_CAL_I2C_Master_Stop_1();
// #else
//Code has been optimised out by the pre-processor
#endif
#endif
#endif
// } else {
}
Or am I missing something here?
DS3231 example with comments as to some problems
[ RTC example - doesn't work.
Martin