AnsweredAssumed Answered

IRTC with Internal clock

Question asked by rajashekargaddam on Jul 4, 2017

hi all,

 

I am using following code when external crystal is removed, but after POR it's not working .

Very first time only it's coming , after POR it's not coming.

Please tell me how to handle this condition.

 

#include "drivers.h"

 

extern volatile uint8_t IRTC_Ram[32];

 

void main (void)

{

FLL_CtrlIRCLKEN(TRUE);

FLL_SelIRCSCLK(FASTCLK_SRC);

MCG_C1 |= MCG_C1_FRDIV(0x02);

 

SIM_SelRtcClk(SIM_RTCCLK_SRC2);

 

SIM_EnableModule(PORTH);

PORT_Init(PORTH,PORT_MODULE_ALT1_MODE, PIN6 );

GPIO_Init(GPIOH,GPIO_OUT_LOGIC0_MODE,PIN6);

 

arch_delay(250000);

GPIO_Set(GPIOH,PIN6);

 

SIM_Init(SIM_MODULE_CONFIG_OPTIMIZED_MODE_ONE);

PMC_Init(PMC_MODULE_LVDRE_OFF_LVDINT_OFF_LVWINT_OFF_CONFIG(PMC_LVDL,PMC_LVW1),PMC_INTREG_BGEN_OFF_BGBE_OFF_CONFIG, PRI_LVL0, (PMC_CALLBACK)NULL);

 

SMC_Init (SMC_MODULE_VLPS_ON_VLLS_ON_CONFIG);

 

SMC_SetMode(RUN);

 

IRTC_Init(IRTC_MODULE_COMP_OFF_CONFIG,

IRTC_TAMPER_PIN_POL_LOW_CONFIG(TAMPER_FILT_CLK_2HZ,4),

IRTC_TAMPER_PIN_DI_CONFIG,

IRTC_TAMPER_PIN_DI_CONFIG, 0);

 

MCG_C8 |= (MCG_C8_CME1_MASK );

MCG_C8 &= ~(MCG_C8_LOCRE1_MASK);

arch_delay(2500000);

GPIO_Clr(GPIOH,PIN6);

 

if((MCG_C8_LOCS1_MASK == (MCG_C8 & MCG_C8_LOCS1_MASK)))

{

FLL_Init (FLL_MODULE_FEI_20_25MHZ_CONFIG);

MCG_C8 |= MCG_C8_LOCS1_MASK;

arch_delay(25000);

}

else

{

SIM_SetClkMode (SYSCLK_MODE1);

SIM_SetClkDiv (SYSCLK_DIV1);

FLL_Init (FLL_MODULE_FEE_24MHZ_CONFIG);

arch_delay(25000);

}

while(1);

}

 

Help in this.,

Outcomes