FM6124 Ramtron Corporation, FM6124 Datasheet - Page 43

no-image

FM6124

Manufacturer Part Number
FM6124
Description
Event Data Recorder With F-ram
Manufacturer
Ramtron Corporation
Datasheet

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
FM6124
Manufacturer:
FM/富满电子
Quantity:
20 000
Part Number:
FM6124-QG
Manufacturer:
ABOV
Quantity:
3 000
////////////////////////////////////////////////////////////////////////////////
// Function:
// Description:
// Parameters:
// Return value:
// Remarks:
////////////////////////////////////////////////////////////////////////////////
rbool
FM6124WriteRTC(struct SBCDDate *a_poDate)
{
}
Rev. 4.0 (EOL)
July 2010
ruint8 l_uiCounter
ruint8 *l_puiDateElement
ruint8 l_uiRTCRegValue
// First, we need to read the RTC register of the FM6124
l_uiRTCRegValue = FM6124ReadReg(EDR_REG_RTC);
// Next, we need to enable the writing of the RTC
l_uiRTCRegValue |= 0x02;
FM6124WriteReg(EDR_REG_RTC, l_uiRTCRegValue);
// Make sure I2C is Idle
while(!(I2CSTATUS & 0x08));
// Wait for TX Buffer to be empty
while((I2CSTATUS & 0x01) == 0);
// Send Write command to Slave Module
I2CRXTX = I2C_ID_EDR | g_uiI2CDevSelect | IC2_WRITE;
// Wait for TX Buffer to be empty
while((I2CSTATUS & 0x01) == 0);
// Make sure we received an ACK and that there was no error during transfer
if (I2CSTATUS & 0xC0)
{
}
// Send Write Address
I2CRXTX = EDR_REG_RTC_SECS;
// Wait for TX Buffer to be empty
while((I2CSTATUS & 0x01) == 0);
// Make sure we received an ACK and that there was no error during transfer
if (I2CSTATUS & 0xC0)
{
}
// Write RTC Data
l_puiDateElement = &(a_poDate->uiSeconds);
for (l_uiCounter = 0; l_uiCounter < 7; l_uiCounter++)
{
}
// Wait for I2C to be Idle, This will generate a STOP
while(!(I2CSTATUS & 0x08));
// Now, we need to restore the original RTC register value.
// Clear "W" bit
// Make sure Oscillator is running: Clear /OSCEN bit
l_uiRTCRegValue &= 0x7D;
FM6124WriteReg(EDR_REG_RTC, l_uiRTCRegValue);
return RTRUE;
return RFALSE;
return RFALSE;
I2CRXTX = *l_puiDateElement;
// Wait for TX Buffer to be empty
while((I2CSTATUS & 0x01) == 0);
// Make sure we received an ACK and that there was no error during transfer
if (I2CSTATUS & 0xC0)
{
}
l_puiDateElement++;
return RFALSE;
FM6124WriteRTC
Write all registers of the RTC of the FM6124.
struct SBCDDate *a_poDate: Date to be written
rbool: RFALSE = Error during read operation.
None
= 0x00;
= NULL;
= 0x00;
Page 43 of 53

Related parts for FM6124