how to output RTCO on FRDM-KE02Z?

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

how to output RTCO on FRDM-KE02Z?

Jump to solution
1,023 Views
jacquesnapoleon
Contributor I

Hello,

Can I find some test codes allowing to output RTCO on PTC5 using FRDM-KE02Z?

Thanks and best regards,

Jacques.

Labels (1)
0 Kudos
1 Solution
840 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Jacques,

According to the fig 1 illustrates , you'll learn that

2015-09-17_10-53-22.jpg2015-09-17_10-54-55.jpg

                                                                          Fig 1


Have a great day,
Ping

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

View solution in original post

0 Kudos
7 Replies
840 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Jacques,

Please check the attachment.
Have a great day,
Ping

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

0 Kudos
840 Views
jacquesnapoleon
Contributor I

Hi Jeremy,

Thanks for your reply.

I already had this kind of project taken from library.

Seems that this output RTCO coming from 1kHz LPO.

I would like to configure RTC clock gated from ICS, then controlling ICSIRCLK gate and SIM RTC/WDOG gate (refer to top of Figure 5-1 clocking diagram from RM).

The output frequency should be 32kHz.

I already tried this but this does not work up to now...

Many thanks and best regards,

Jacques.

0 Kudos
840 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Jacques,

In the demo, the 1kHz LPO as the clock source of the RTC, and it's supported to select other clock source.

I was wondering if you can tell what issue you stuck in.

2015-09-16_10-09-52.jpg
Have a great day,
Ping

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

0 Kudos
840 Views
jacquesnapoleon
Contributor I

Hi Jeremy,

Thanks for your reply and you help on this topic.

I already tried this but it cannot make appearing 32kHz frequency to RTCO pin.

I only want to use 32kHz IRC as an external signal to drive external components...

I modified the initial code as shown below.

In that case, I observed ~19.73kHz on RTCO pin which it supposed to be the 39,0625kHz divided by 2 (?), as if PTC5 output FTM signal (ICSFFCLK/2) instead of ICSIRCLK... However, RTC0 pin is well assigned to PTC5 in SIM_PINSEL as RTCS = 1...

Thanks and best regards,

Have a nice day!

Jacques.

int main (void)

{

    uint8_t         u8Ch;

    ICS_ConfigType  sICSConfig;

    RTC_ConfigType  sRTCConfig;

    RTC_ConfigType  *pRTCConfig = &sRTCConfig;      

    UART_ConfigType sConfig;

    ICS_Trim(ICS_TRIM_VALUE);

    LED0_Init(); 

    LED2_Init();

    /* configure RTC to 1Hz interrupt frequency */

    pRTCConfig->u16ModuloValue = 0;

    pRTCConfig->bRTCOut=RTC_OUTPUT_ENABLE;

    pRTCConfig->bInterruptEn   = RTC_INTERRUPT_ENABLE;     /* enable interrupt */

    pRTCConfig->bClockSource   = RTC_CLKSRC_IREF;          /*clock source is 1khz*/

    pRTCConfig->bClockPresaler = RTC_CLK_PRESCALER_128;    /*prescaler is 100*/

    SIM->PINSEL |=SIM_PINSEL_RTCPS_MASK;

   

    RTC_SetCallback(RTC_Task);

    RTC_Init(pRTCConfig);

    /* Enable IRCLK */

    ICS->C1 |= 0x02;

    /* switch clock mode from FEE to FEI */

    sICSConfig.u32ClkFreq = 32;     /* NOTE: use value 32 for 31.25KHz to 39.0625KHz of internal IRC */

    ICS_SwitchMode(FEE,FEI, &sICSConfig);

    while(1)

    {

    }

}

0 Kudos
841 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Jacques,

According to the fig 1 illustrates , you'll learn that

2015-09-17_10-53-22.jpg2015-09-17_10-54-55.jpg

                                                                          Fig 1


Have a great day,
Ping

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

0 Kudos
840 Views
jacquesnapoleon
Contributor I

Hello Ping,

Thanks for your reply.

This could explain the frequency observed...

BTW, where this formula comes from, I did not find it in the reference manual...?

Thanks and best regards,

Jacques.

0 Kudos
840 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Jacques,

The formula is created by myself, by using this formula, I think it can help you to understand it easily.
Have a great day,
Ping

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

0 Kudos