DEFINE AN RTC INTERRUP ROUTINE

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

DEFINE AN RTC INTERRUP ROUTINE

472 Views
matiasraimondo
Contributor I

HI, I AM TRYING TO RUN A ROUTINE WITH THE RTC MODULE OF AN KE02P64. I LEARNED HOW TO DO IT ON A C9S08JM60, BUT IT SEEMS TO BE A LITTLE BIT DIFFERENT. THE EXAMPLE ON THE REFERENCE MANUAL IS:

/* Initialize the elapsed time counters */

Seconds = 0;

Minutes = 0;

Hours = 0;

Days=0;

/* Configure RTC to interrupt every 1 second from OSC (32.768KHz) clock source */

RTC_MOD = 511; // overflow every 32 times

RTC_SC = RTC_SC_RTCPS_MASK; // external 32768 clock selected with 1/64 predivider.

RTC_SC = RTC_SC_RTIF_MASK | RTC_SC_RTIE_MASK; // interrupt cleared and enabled

/**********************************************************************

Function Name : RTC_ISR

Notes : Interrupt service routine for RTC module.

**********************************************************************/

void RTC_ISR(void)

{

/* Clears the interrupt flag, RTIF, and interrupt request */

RTC_SC |= RTC_SC_RTIF_MASK;

/* RTC interrupts every 1 Second */

Seconds++;

/* 60 seconds in a minute */

if (Seconds > 59)

{

Minutes++;

Seconds = 0;

}

/* 60 minutes in an hour */

if (Minutes > 59)

{

Hours++;

Minutes = 0;

}

/* 24 hours in a day */

if (Hours > 23)

{

Days ++;

Hours = 0;

}}

I UNDERSTAND THE INITIALIZATION BUT I DO NOT KNOW HOW TO DEFINE THAT (IN THIS PARTICULAR CASE) THE void RTC_ISR(void) ROUTINE RUNS WHEN A RTC INTERRUP OCCURS.

I REMEMBER IN THE C9S08JM60 I DEFINE THE VECTOR FOR THE INTERRUPT. SHOULD I DO THE SAME IN THIS ONE?

ENGLISH IS NOT MY FIRST LANGUAGE, THANK YOU FOR UNDESTAND.

Labels (1)
0 Kudos
1 Reply

283 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

Customer could refer KE02 RTC example code from attached demo, or find from CodeWarrior MCU V10.6 installation default path:

C:\Freescale\CW MCU v10.6\MCU\CodeWarrior_Examples\Kinetis_Examples\KE\build\cw\ke02\RTC_demo

It re-define the RTC interrupt vector table to point to RTC interrupt service routine at <isr.h> file.

/*!

* @brief define interrupt service routine for different vectors.

*

*/

#undef  VECTOR_036

#define VECTOR_036      RTC_Isr    /*!< Vector 36 points to RTC interrupt service routine */

More detailed info, please check attached code.


Wish it helps.
best regards
Ma Hui

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

0 Kudos