Showing results for 
Search instead for 
Did you mean: 


Contributor IV

Hello Everyone,


Basically, what i try to accomplish is to read one particular ADC channel let's say every second or two. I'm using the 9S08QE32 uC and it has a few options for timing,I can either use the RTC or TPM. What are the pros and cons of using one over the other ?

Labels (1)
0 Kudos
2 Replies

NXP TechSupport
NXP TechSupport

Hi Designer11,

Basically, RTC and TPM use different clock source. TPM is more powerful and multifunctional.  TPM is more accurate. For detail, see:

Features of the RTC module include:

• 8-bit up-counter

— 8-bit modulo match limit

— Software controllable periodic interrupt on match

• Three software selectable clock sources for input to prescaler with selectable binary-based and

decimal-based divider values

— 1-kHz internal low-power oscillator (LPO)

— External clock (ERCLK)

— 32-kHz internal clock (IRCLK)

The TPM includes these distinctive features:

• One to eight channels:

— Each channel is input capture, output compare, or edge-aligned PWM

— Rising-edge, falling-edge, or any-edge input capture trigger

— Set, clear, or toggle output compare action

— Selectable polarity on PWM outputs

• Module is configured for buffered, center-aligned pulse-width-modulation (CPWM) on all


• Timer clock source selectable as bus clock, fixed frequency clock, or an external clock

— Prescale taps for divide-by 1, 2, 4, 8, 16, 32, 64, or 128 used for any clock input selection

— Fixed frequency clock is an additional clock input to allow the selection of an on chip clock

source other than bus clock

— Selecting external clock connects TPM clock to a chip level input pin therefore allowing to

synchronize the TPM counter with an off chip clock source

• 16-bit free-running or modulus count with up/down selection

• One interrupt per channel and one interrupt for TPM counter overflow


this answer is for you. if it helps, please click on "correct answer" button. thanks!

Best Regards,

Zhang Jun

Contributor III

Hello Designer11, it sounds like you are not very worried about accuracy ... you need a sample every one or two seconds. 9S08QE32 has ***lots*** of timing sources. A simple one: take any free TPM module and take the bus clock as clock source for the counter. If your CPU bus clock is for example 10.000 MHz, set the the MODULO of the TPM to 10000. This will produce an overflow of the counter every 1 ms. Enable the Timer Overflow interface to trap this event every 1 ms. Now, write an interrupt function or routine related to the Timer Overflow event of this TPM, don't forget to clear the TOF flag on every interrupt first thing to do before your interrupt handler code. Then, use an int or 16 bit variable to decrement from 10000 to zero, and reload this cell when this happens every one second. You must initialize this variable with 10000 before enabling interrupts. Once you have this one second event ready, write the code to access the ADC result and store it in a variable. Now trigger an ADC convertion that you will read on the next second with this same procedure.

#define ONESECOND 10000

unsigned int adresult;

/* here every 1 ms timer overflow event */




     static unsigned int div = ONESECOND;

     if( --div == 0 )


          div = ONESECOND;


          adresult = get_ad_result();



Good luck !