Diference between Timer Interrupt and RTI

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

Diference between Timer Interrupt and RTI

4,824 Views
DiegoNunes
Contributor I
1) I want to know what is the diference between Timer Interrupt and Real-Time Interrupt.
2) If I disable interruptions (SEI in asm), the will timers go off? If both go off, will I get some clock count loss? (in 24 hour clock tick count will I get less ticks?)
3) In NE64 with 25MHz xtal, is it possible get 1 milisecond precision timer?
 
Diego.
Labels (1)
0 Kudos
7 Replies

1,139 Views
mjbcswitzerland
Specialist V
Hi Diego

1. Not sure if the question is related to NE64 but if it is I assume difference is between 16 bit timer and Period Interrupt Timer. In this case the PIT is designed to give a periodic interrupt and has no frills (the 16 bit timer can be used for a number of jobs such as counting extrernal pulses, generating waveforms and of course generating a simple periodic interrupt like the PIT - this can however be considered as under use of 16 bit timer when a PIT is otherwise available). I believe however that the PIT in the NE64 can not generate longer delays than 40ms when running from a 25MHz oscillator.

2. If the questions are related to above timers, when interrupts are disabled during several TICK, only one interrupt will be counted so time is lost.

3. These are my figures for the NE64 using a 16 bit timer and 25MHz oscillator and various prescaler set ups (from the uTasker project)
LOW_RES_MS - Clock with prescale 128 = about 0.16% accurate ms values, 2.5us resolution and limit of about 168ms max.
MED_RES_MS - Clock with prescale 32 = about 0.01% accurate ms values, 0.64us resolution and limit of about 42ms max.
HIGH_RES_MS - Clock with prescale 4 =  about 0% accurate ms values, 0,16us resolution and limit of about 10.5ms max.

With prescaler 4 it is possible to generate ms delay with perfect accuracy by using a match value of 6250. However don't forget that if an interrupt routine handles this it may well have an extra response time of several % of the accuracy value until it used the TICK - and more if it has to wait for code which is blocking interrupts.

Regards

Mark

PS. Did you finally get the NE64 BDM working?

www.uTasker.com

0 Kudos

1,139 Views
DiegoNunes
Contributor I
HI Mark,
If I use PIT, will I loss some IOC port?
Can RTI be not maskable?
0 Kudos

1,139 Views
mjbcswitzerland
Specialist V
Hi Diego

The PIT is independent from the timer(s) so its use doesn't cause any loss of timer functionality (as far as I know).

The NE64 has a default priority order where the PIT has in fact has almost highest - a single interrupt source can be elevated to highest priority (see HPRIO register) but I don't think that NMI status is obtainable. (Only Interrupts like SWI, TRAP or Background debug have NMI status).

[If you were using a Coldfire timer it can be set to priority level 7 which gives them NMI status.]

Regards

Mark
0 Kudos

1,139 Views
DiegoNunes
Contributor I
Mark,
 
 
But with RTI, I cannot use a prescaler lower than 1024.


Message Edited by DiegoNunes on 2007-06-28 08:04 PM
0 Kudos

1,139 Views
mjbcswitzerland
Specialist V
Diego

PIT == RTI.
Sorry for confusion - on some devices, like the Coldfire, it is called PIT = Periodic Interrupt Timer.

That is correct, there is a fixed prescaler of 1024 and the longest interrupt period is limited to about 40ms with 25MHz crystal.

In the following code from the uTasker project the user specifies the system TICK period in ms using TICK_RESOLUTION
(eg. #define  TICK_RESOLUTION    40  in config.h) which generates the most accurate rate possible but limited by the capabilities of the simple RTI circuitry.

// Routine to initialise the Real Time Tick interrupt//#define REQUIRED_MS ((1000/TICK_RESOLUTION))                             // The TICK frequency we require in kHz#define TICK_DIVIDE (OSCCLK/REQUIRED_MS)                                 // the divide ration required#define REGISTER_VALUE (((TICK_DIVIDE + 65536/2)/65536) - 1)             // we assume 2^16 prescaler to give range 2.5...40msextern void fnStartTick(void){  RTICTL = (0x70 + REGISTER_VALUE);                                      // set the prescaler to generate the periodic tick  CRGFLG = RTIF;                                                         // Reset interrupt request flag  CRGINT = RTIE;                                                         // Enable interrupt}

 If longer delays or more  accurate resolution is necessary the use of the Timer module is the only way out.

Regards

Mark

0 Kudos

1,139 Views
DiegoNunes
Contributor I
Mark, just to get conclusion:
Using timer module will lose some Input Capture or Output Capture port?
0 Kudos

1,139 Views
mjbcswitzerland
Specialist V
Hi Diego

Using the 16 bit timer for periodic interrupts will certainly restrict its use and so should be avoided if the job can be performed using the PIT.

Just what you lose depends on what is required from the timer. The timer has 4 channels and can be used for input capture, generating interrupts and for generating waveforms. Since the main timer counter will be in use for the TICK, it will put restrictions on its use for other purposes, making it less flexible or even impossible - depending on what is required.

As an example. If you look at the following online project via web cam: http://84.253.57.46:8080/
where you can contol it at http://84.253.57.46:8081/0 you will see an LCD being controlled by an NE64.
Via web browser you can control its contrast and intensity and, if you could press on its keys and hear it you would hear a beep. These three functions (contrast control, backgound intensity and key beep) are controlled by the 16 bit timer. Two of the channels are set to generate PWM signals for intensity controls and one can be gated from the main clock rate (set to about 3kHz). I don't know whether it would be possible to also set up a TICK interrupt as well (although I haven't actually studied it). In the project the PIT is fine for a 40ms TICKER so that's what it is used for.

Cheers

Mark



0 Kudos