IRtc ram when crystal removed

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

IRtc ram when crystal removed

1,302 Views
darshandpatel
Contributor II

Hi In nxp mkm34z256vll7 I removed external rtc crystal and there is no other external crystal, in this condition I am trying to read the iRtc RAM. But I am unable to see any controller register and controller behaviour also undesired. Please tell me how to get out from this.As I want to read the iRtc ram and it's variable. Thank & Regards, Darshan.

Labels (1)
0 Kudos
9 Replies

1,015 Views
MarMi
NXP Employee
NXP Employee

Hi Darshan,

IRTC is clocked from external RTC crystal by default and therefore optional 32kHz internal oscillator must be selected as the IRTC clock source provided external RTC crystal has been removed.

For more details, refer to the SIM_SelRtcClk(SIM_RTCCLK_SRC2) macro that is included in bare metal drivers releases for Kinetis-M microcontroller families.

Kind regards,

Martin M. 

0 Kudos

1,015 Views
darshandpatel
Contributor II

Hi Martin 

Thanks for reply,

Before main function only in startup code I am using that initializations . But than also it's not working .

Darshan.

0 Kudos

1,015 Views
MarMi
NXP Employee
NXP Employee

Hi Darshan,

not aware of any other settings to allow reading from irtc ram. There is an irtcram_test example in bare metal drivers releases for Kinetis-M microcontroller families - description attached. You could run this example with added SIM_SelRtcClk(SIM_RTCCLK_SRC2) to see response.

Kind regards,

Martin M.

0 Kudos

1,015 Views
darshandpatel
Contributor II

Hi Martin ,

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 for the same .

#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.,

Thanks and regards,

Darshan.

0 Kudos

1,015 Views
MarMi
NXP Employee
NXP Employee

Hi Darshan,

in code you initialize device, namely SIM, IRTC and FLL, using mixed driver's Init functions, macros and by setting peripheral registers directly in C. This way of initialization might not be optimal because Init functions are intended to set all peripheral registers and therefore they might change first settings performed by macros or coded in C.

I assume that you don't have crystal but need access to IRTC RAM along with FLL running clocking your device to operate @ ~20 MHz. Do you need also IRTC running on internal clock? Please send me brief use-case description and I will prepare example of device initialization for you.

Kind regards,

Martin M.

0 Kudos

1,015 Views
darshandpatel
Contributor II

Hi Martin,

As from our conversation I thought you understanding that iRtc only not working, but iRtc is working very first initializations also happened, but after POR again iRtc not getting initialized.

Upto initializations code is working after coming to irtc initializations controller itself only not working.

Regards,

Darshan

0 Kudos

1,015 Views
MarMi
NXP Employee
NXP Employee

Hi Darshan,

sorry for delay in responding but was on vacation and also had to make a quick board with MKM34Z256VLL7 device with no external crystal.

I have attached example of:

  • FLL generating ~ 20 MHz system clock with frequency sourced from 32kHz internal oscillator
  • IRTC running from 32 kHz  internal oscillator
  • IRTC generating 1 Hz interrupt and writing periodically value into IRTC RAM while reading the same value periodically in a while loop
  • MKM34Z256VLL7 device is just powered and interconnected with J-link (no external crystals connected)

Please look at this example whether it solves your problem or not. Try to leverage high level configuration / init functions going further with configuration structures optimized to your application.

Kind regards,

Martin M. 

0 Kudos

1,015 Views
darshandpatel
Contributor II

hi Martin ,

thanks again for reply.

My requirement is i don't have crystal but need to access to IRTC RAM along with FLL running clocking @~24MHz.

I need also IRTC running on internal clock.

My use-case to switch to FEE mode to FEI mode @~24MHz, when external crystal has failed.

Please send me example on this.

Thanks & regards,

Darshan.

0 Kudos

1,015 Views
darshandpatel
Contributor II

Hi Martin,

Thanks again but in that bare metal example code iRtc ram reading and writing is there but my problem is I am not getting access to the CPU register.

Can you have any ideas how to get off from this.

I am using multi link PE micro emulator.

Thanks and regards

Darshan.

0 Kudos