RTC PCA 21125 Issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

RTC PCA 21125 Issue

423 Views
AshBirari
Contributor I

Hello NXP ,

I am facing issue with RTC as listed below :

1. after a power reset on the complete hardware, I only get the expected data after flashing the software multiple times. So I would like to ask if PCA21125 chip has any internal battery back up like Super capacitor or Battery ?

2. I am facing issue while overwriting the default values of the PCA21125 chip.

3. My time parameters like Second, Minute or any other are not incrementing.

Please help me out with this , I am struggling with this chip PCA21125 for long.  .Please share a sample code for RTC PCA21125 SPI communication with me.Most of my post does not get response.

0 Kudos
4 Replies

407 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hello Ashwini,

The PCA21125 does not have any internal battery backups.

As far as I know, there is currently no sample code/project available for PCA21125 RTC from NXP.

If the time is not incrementing, please check the reasons I mentioned before here.

BR, Tomas

0 Kudos

403 Views
AshBirari
Contributor I
I have checked the CLOCK as you mentioned its ENABLED.
I am able to See the whatever Configurations or Initialization data and write Command on SDI line through oscilloscope but If I send read command the same Initialization registers I am getting default values of those register on the SDO lines, so where exactly issue might be there ? Why I am not able to overwrite the register bits even for Initialization of RTC
0 Kudos

402 Views
AshBirari
Contributor I
Our Hardware does not have any Super Capacitor connected to it
You can check through the code .
Init Function for RTC :
FUNC(CDD_RTC_StatusType, CDD_RTC_PCA) Cdd_Rtc_Init_ab()
{
VAR(Std_ReturnType, TYPEDEF) RetVal = E_OK;
VAR(CDD_RTC_StatusType, TYPEDEF) eStatus = CDD_RTC_OK;

/* Set SPI to Sync Mode for Driver initialization */
Cdd_u8RTC_SPIMode = CDD_RTC_SYNC_Mode;


RetVal |= Cdd_Rtc_RegCtrl1Init_Ab();
// CDDLib_DelayInUs(1);
Cdd_Rtc_ReadReg_ab(REG_CONTROL_1);
Cdd_PCAReg.RegCntrl_1.uint8_reg = Cdd_Rtc_Spi_RxBuff[1];

RetVal |= Cdd_Rtc_RegCtrl2Init_Ab();
// CDDLib_DelayInUs(1);
Cdd_Rtc_ReadReg_ab(REG_CONTROL_2);
Cdd_PCAReg.RegCntrl_2.uint8_reg = Cdd_Rtc_Spi_RxBuff[1];
RetVal |= Cdd_Rtc_ClrRf_ab();
// CDDLib_DelayInUs(1);
Cdd_Rtc_ReadReg_ab(REG_SECONDS);
Cdd_PCAReg.RegSeconds.uint8_reg = Cdd_Rtc_Spi_RxBuff[1];

if(E_OK == RetVal)
{
eStatus = CDD_RTC_OK;

/* Initialize RTC state to Idle */
Cdd_u8RTCState = IDLE_STATE;

Cdd_u8RTC_SPIMode = CDD_RTC_SPI_MODE_CFG;
}
else
{
eStatus = E_NOT_OK;
}
return eStatus;
}
// RF Clear Function :
FUNC(CDD_RTC_StatusType, CDD_RTC_PCA) Cdd_Rtc_ClrRf_ab(void)
{
VAR(uint16, AUTOMATIC) DataIndex = INDEX_ZERO;
VAR(Std_ReturnType, TYPEDEF) RetVal = E_OK;
VAR(CDD_RTC_StatusType, TYPEDEF) eStatus = CDD_RTC_OK;


Cdd_PCAReg.RegSeconds.bit.RF = CDD_RF_CLR;
Cdd_Rtc_Spi_TxBuff[DataIndex++] = WRITE_CMD | REG_SECONDS;
Cdd_Rtc_Spi_TxBuff[DataIndex++] = Cdd_PCAReg.RegSeconds.bit.RF;
//Dio_WriteChannel(7, CS_PIN_SET);
//CDDLib_DelayInUs(10000);
RetVal |= Spi_SetupEB(CDD_RTC_SPI_CHNL, &Cdd_Rtc_Spi_TxBuff[INDEX_ZERO], &Cdd_Rtc_Spi_RxBuff[INDEX_ZERO],DataIndex);
/* Send Data over SPI */
RetVal |= Cdd_Rtc_SpiSend_Ab();
// Check if SPI transfer successful
if(E_OK != RetVal)
{
eStatus = CDD_SPI_FAILURE;
}
else
{
// SPI transfer successful

// Is SPI Async communication mode selected?
if(CDD_RTC_ASYNC_MODE == Cdd_u8RTC_SPIMode)

{ //Set status to operation pending
Cdd_eRTC_Status = CDD_OPRN_PEND;

// Change state to "Write In Progress" state
Cdd_u8RTCState = WRITE_IN_PROG_STATE;
}
else
{
/* Do nothing */
}
}

return eStatus;
}
// RegControl_1 Init Function :
FUNC(CDD_RTC_StatusType, CDD_RTC_PCA) Cdd_Rtc_RegCtrl1Init_Ab(void)
{
VAR(uint16, AUTOMATIC) DataIndex = INDEX_ZERO;
VAR(Std_ReturnType, TYPEDEF) RetVal = E_OK;
VAR(CDD_RTC_StatusType, TYPEDEF) eStatus = CDD_RTC_OK;

//Cdd_PCAReg.RegCntrl_1.uint8_reg = REGCTRL1_INTI_VAL;
// Cdd_PCAReg.RegCntrl_1.uint8_reg = 0x00;

Cdd_Rtc_Spi_TxBuff[DataIndex++] = WRITE_CMD | REG_CONTROL_1;
Cdd_Rtc_Spi_TxBuff[DataIndex++] = 0x0C;
//Dio_WriteChannel(7, CS_PIN_RESET);
//CDDLib_DelayInUs(10000);
//Cdd_Rtc_Spi_TxBuff[1] = (((Cdd_Rtc_Spi_TxBuff[1] & 0x0F)<<4) | ((Cdd_Rtc_Spi_TxBuff[1] & 0xF0)>>4));
RetVal |= Spi_SetupEB(CDD_RTC_SPI_CHNL, &Cdd_Rtc_Spi_TxBuff[INDEX_ZERO], &Cdd_Rtc_Spi_RxBuff[INDEX_ZERO], DataIndex);
/* Send data filled in SPI buffer over SPI */
//Dio_WriteChannel(7, CS_PIN_SET);
RetVal |= Cdd_Rtc_SpiSend_Ab();
/* Set CE (CS pin) to Low */
//Dio_WriteChannel(7, CS_PIN_RESET);
/* Delay */
//CDDLib_DelayInUs(100000);
/* Check if SPI transfer successful */
if(E_OK != RetVal)
{
eStatus = CDD_SPI_FAILURE;
}
else
{
/* SPI transfer successful */

/* Is SPI Async communication mode selected? */
if(CDD_RTC_ASYNC_MODE == Cdd_u8RTC_SPIMode)
{
/* Set status to operation pending */
Cdd_eRTC_Status = CDD_OPRN_PEND;

/* Change state to "Write In Progress" state */
Cdd_u8RTCState = WRITE_IN_PROG_STATE;
}
else
{
/* Do nothing */
}
}

return eStatus;
}
// Reg Control_2 Function :
FUNC(CDD_RTC_StatusType, CDD_RTC_PCA) Cdd_Rtc_RegCtrl2Init_Ab(void)
{
VAR(uint16, AUTOMATIC) DataIndex = INDEX_ZERO;
VAR(Std_ReturnType, TYPEDEF) RetVal = E_OK;
VAR(CDD_RTC_StatusType, TYPEDEF) eStatus = CDD_RTC_OK;

Cdd_PCAReg.RegCntrl_2.uint8_reg = 0x00;
Cdd_Rtc_Spi_TxBuff[DataIndex++] = WRITE_CMD | REG_CONTROL_2;
Cdd_Rtc_Spi_TxBuff[DataIndex++] = Cdd_PCAReg.RegCntrl_2.uint8_reg;
//Dio_WriteChannel(7, CS_PIN_SET);
//CDDLib_DelayInUs(10000);
RetVal |= Spi_SetupEB(CDD_RTC_SPI_CHNL, &Cdd_Rtc_Spi_TxBuff[INDEX_ZERO], &Cdd_Rtc_Spi_RxBuff[INDEX_ZERO], DataIndex);
/* Send data filled in SPI buffer over SPI */
RetVal |= Cdd_Rtc_SpiSend_Ab();
/* Set CE (CS pin) to Low */
//Dio_WriteChannel(7, CS_PIN_SET);
/* Delay */
//CDDLib_DelayInUs(100000);
/* Check if SPI transfer successful */
if(E_OK != RetVal)
{
eStatus = CDD_SPI_FAILURE;
}
else
{
/* SPI transfer successful */

/* Is SPI Async communication mode selected? */
if(CDD_RTC_ASYNC_MODE == Cdd_u8RTC_SPIMode)

{
/* Set status to operation pending */
Cdd_eRTC_Status = CDD_OPRN_PEND;

/* Change state to "Write In Progress" state */
Cdd_u8RTCState = WRITE_IN_PROG_STATE;
}
else
{
/* Do nothing */
}
}

return eStatus;
}
// Read Register API
Std_ReturnType Cdd_Rtc_ReadReg_ab(uint8 reg)
{
uint16 DataIndex = INDEX_ZERO;
Std_ReturnType RetVal = E_OK;
CDD_RTC_StatusType eStatus = CDD_RTC_OK;

Cdd_Rtc_Spi_TxBuff[DataIndex++] = READ_CMD | reg;
/* Transmitting Data */
Cdd_Rtc_Spi_TxBuff[DataIndex++] = 0x00;
Cdd_Rtc_Spi_TxBuff[1] = (((Cdd_Rtc_Spi_TxBuff[1] & 0x0F)<<4) | ((Cdd_Rtc_Spi_TxBuff[1] & 0xF0)>>4));
RetVal |= Spi_SetupEB(CDD_RTC_SPI_CHNL, &Cdd_Rtc_Spi_TxBuff[INDEX_ZERO], &Cdd_Rtc_Spi_RxBuff[INDEX_ZERO], DataIndex);
/* Set CE (CS pin) to High */
// Dio_WriteChannel(7, CS_PIN_RESET);
/* Sends the Data Over SPI */
CDDLib_DelayInUs(0.045);
RetVal |= Cdd_Rtc_SpiSend_Ab();
/* Set CE (CS pin) to Low */
// Dio_WriteChannel(7, CS_PIN_SET);
/* Delay */
//CDDLib_DelayInUs(100000);
// Check if SPI transfer successful
if(E_OK != RetVal)
{
eStatus = CDD_SPI_FAILURE;
}
else
{
// SPI transfer successful
// Is SPI Async communication mode selected?
if(CDD_RTC_ASYNC_MODE == Cdd_u8RTC_SPIMode)

{ //Set status to operation pending
Cdd_eRTC_Status = CDD_OPRN_PEND;



// Change state to "Write In Progress" state
Cdd_u8RTCState = WRITE_IN_PROG_STATE;
}
else
{
/* Do nothing */
}
}

return eStatus;
}
Please suggest your opinion for this code
0 Kudos

387 Views
AshBirari
Contributor I

Hello,

any comments on code I have shared. You quick reply will be much helpful and appreciable. 

0 Kudos