MKW30Z; KSDK board disable hw RTC

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

MKW30Z; KSDK board disable hw RTC

907 Views
lucianfiran
Contributor V

KW40Z_Connectivity_Software_1.0.1 (KSDK_1.3.0); IAR 7.50

 

175639_175639.pngpastedImage_1.png

How to set-up these files if you want not to use RTC clock.

To disable it.

 

48QFN, 32QFN,PinName    ,DEFAULT    ,ALT0           ,ALT1 ,ALT2 ,ALT3 ,ALT4 ,ALT5 ,ALT6 ,ALT7

21,        15        ,PTB16        ,EXTAL32K   ,EXTAL32K  ,PTB16 ,— ,I2C1_SCL,— ,TPM2_CH0,— ,—
22,        16        ,PTB17        ,XTAL32K      ,XTAL32K    ,PTB17 ,— ,I2C1_SDA,— ,TPM2_CH1,— ,—

 

Should  RTC the pins be mux-ed to ALT1 or left default if pin open (NC) ?

 

Should be modified  BOARD_ClockInit -> BOARD_InitRtcOsc() functions  ?

 

RTC pins on PCB are left open, should be tied to 3.3V ot GND ?

 

If the HW RTC is disabled can other sw clock be used instead for time keeping ?

 

How accurate are other timers if DCDC bypass mode is used ?

 

Standard time.h lib is supported ?

 

Best Regards,

Lucian

Labels (1)
Tags (3)
6 Replies

644 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Lucian Firan

Sorry if I don't understand your question, what do you mean with "not to use RTC clock". If you don't want to use the RTC module, you could comment the BOARD_InitRtcOsc(); function located in the BOARD_ClockInit, there is not need to get involve with the pins.

But if what you want is not to put a external crystal, then you going to need to change the clock initialization, cecause most of the examples in connectivity software are set to run in BLPE mode, where MCGOUTCLK is derived from the OSCSEL external reference clock.

You can change the Clock configuration in the following part:

CLOCK_SetBootConfig(&g_defaultClockConfigRun);

As you can see here, it used the g_defaultClockConfigRun witch is defined in board.c.

About time.h; this library is in IAR IDE, but you need to defined your own APIs functions witch use them, Connectivity software doesn't provide examples using this library.


Hope this information helps you
Have a great day,
Jorge Alcala

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

644 Views
lucianfiran
Contributor V

Hello Jorge,

Some boards might have 32KHz crystal oscillator solder to them and yes others may have not.

In the situation that there is no rtc crystal oscillator used and not soldered on PCB should I change:

g_defaultClockConfigRun  to g_defaultClockConfigRunNo32KHzQ

there is an example with this setting ?

Should I change something else like:

    // OSC0 has not configuration register, only set frequency
    MCG_WR_C2_RANGE(MCG,kOscRangeHigh);
    g_xtal0ClkFreq = 32000000U;

or

    /* set TPM clock */
    CLOCK_SYS_SetTpmSrc(0, kClockTpmSrcOsc0erClk); 

Also kMcgModeBLPI should be updated to kMcgModeFBI or kMcgModePBI

Thank you,

Lucian

0 Kudos

644 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Lucian

No, I don't think that there is available an example code of FRDM-KW40Z not using the OSC, but you can implement it in this part BOARD_ClockInit. What you need to do is to define your custom g_defaultClockConfigRunNo32KHzQ as it is defined the g_defaultClockConfigRun and the g_defaultClockConfigVlpr (in board.c).

Yes if you aren't going to use and external crystal oscullator you need to change BOARD_InitOsc0(); BOARD_InitRtcOsc(); CLOCK_SetBootConfig(&g_defaultClockConfigRun); and CLOCK_SYS_SetTpmSrc(0, kClockTpmSrcOsc0erClk); because all of them use the external crystal.

And yes, you also need to Arun the MCU from internal oscilators, changing kMcgModeBLPI to kMcgModeFBI or kMcgModePBI. All of this is done in the definition of your custom g_defaultClockConfigRunNo32KHzQ.


Hope this information helps you
Have a great day,
Jorge Alcala

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

644 Views
lucianfiran
Contributor V

Hi Jorge,

So you don't see any potential problems if new PCB will not have soldered the RTC 32KHz crystal oscillator on the PCB

and correct hardware_init is updated ?

I hope this set-up will be provided in next KSDK releases.

Best Regards,

Lucian

0 Kudos

644 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Lucian

Yes, you could use internal clocks for the core clock for example, but as you mentioned , you will need to update your hardware_init. This apply just for the 32KHz crystal, the 32MHz it is needed for the RF module, so you cannot remove it.


Hope this information helps you
Have a great day,
Jorge Alcala

644 Views
lucianfiran
Contributor V

Observations:

hardware_init.c -> hardware_init function
BOARD_ClockInit()

{
    /* Set allowed power mode, allow all. */
    SMC_HAL_SetProtection(SMC, kAllowPowerModeAll);

    /* Setup board clock source. */
    // Setup OSC0 if used.
    // Configure OSC0 pin mux.
    PORT_HAL_SetMuxMode(EXTAL0_PORT, EXTAL0_PIN, EXTAL0_PINMUX);
    PORT_HAL_SetMuxMode(XTAL0_PORT, XTAL0_PIN, XTAL0_PINMUX);

    BOARD_InitOsc0();
    BOARD_InitRtcOsc();

The SetMuxMode functions seems to set the RTC pins PTB16 (EXTAL32K) and PTB17 (XTAL32K) not osc0
Strange defined in board.h

/* EXTAL0 PTA18 */
#define EXTAL0_PORT   PORTB
#define EXTAL0_PIN    17
#define EXTAL0_PINMUX kPortPinDisabled


/* XTAL0 PTA19 */
#define XTAL0_PORT   PORTB
#define XTAL0_PIN    16
#define XTAL0_PINMUX kPortPinDisabled

Should be:
48QFN,32QFN,PinName,DEFAULT    ,ALT0     ,ALT1 ,ALT2 ,ALT3 ,ALT4 ,ALT5 ,ALT6 ,ALT7
21,15,PTB16        ,EXTAL32K   ,EXTAL32K ,PTB16 ,— ,I2C1_SCL,— ,TPM2_CH0,— ,—
22,16,PTB17        ,XTAL32K    ,XTAL32K ,PTB17 ,— ,I2C1_SDA,— ,TPM2_CH1,— ,—

-----

/* Function to initialize OSC0 base on board configuration. */
void BOARD_InitOsc0(void)
{
    // OSC0 has not configuration register, only set frequency
    MCG_WR_C2_RANGE(MCG,kOscRangeHigh);
    g_xtal0ClkFreq = 32000000U;
}

 

pag 102
MKW40Z/30Z/20Z Reference Manual, Rev. 1.2, 10/2015

pastedImage_1.png

pag 156

6.2.2.5 Multipurpose clock generator loss-of-clock (LOC)
The MCG module supports external reference clocks.
If MCG_C6[CME] is set, the clock monitor associated with the RF reference oscillator is
enabled. If the external reference falls below f
loc_low or floc_high, as controlled by
MCG_C2[RANGE], the MCU resets. MCG_SC[LOCS0] and [RCM_SRS0[LOC] are set
to indicate this reset source.
If MCG_C8[CME1] is set, the clock monitor associated with the RTC oscillator is
enabled. If the external reference falls below f
loc_low, the MCU resets. MCG_C8[LOCS1]
and RCM_SRS0[LOC] are set to indicate this reset source.

page 407

Chapter 24 Multipurpose Clock Generator (MCG)

0 Kudos