NE64 periodic timeout

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

NE64 periodic timeout

2,503 Views
PsychoDebugger
Contributor I
Hi, i'm using MCUS12NE64.
I read about Timer in datasheet, but i've not yet undestood,
how to simple generate an interrupt every 5 ms.
I need to execute some periodical functions,
can you help me with any examples?
Labels (1)
0 Kudos
Reply
3 Replies

558 Views
mjbcswitzerland
Specialist V
Hi

The following can be used to initialise the PIT to generate a periodic interrupt in the range from 2.5ms to 40ms on the NE64 (25MHz clock)

#define TICK_RESOLUTION    5   // 5ms rate setting
#define OSCCLK                       25000000

// 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...40ms

extern 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
}



/**************************** Real Time Clock interrupt ******************************************/

__interrupt void RealTimeInterrupt(void)
{
 CRGFLG = RTIF;                                                         // Reset interrupt request flag
 // do other stuff her every 5ms.....
}


Regards

Mark

www.uTasker.com

0 Kudos
Reply

558 Views
PsychoDebugger
Contributor I
That's great and I' ll going to try your code.

This code use the CRG module to generate the real time interrupt.
I'm using OpenTcp stack and i fear that this kind of interrupt
is just used to decrement some timers.

I prefer to use the timer module that is unused,
do you know how to use it to do the the same task?

In the meantime i'll try your solution.

Thank you

0 Kudos
Reply

558 Views
PsychoDebugger
Contributor I
I've done it.
It was the outcompare function.

Here' s the code if can be useful, i hope it's right,
I try it with a led that is on and off every second.

Code:
void timeout_5ms(void){  TIOS_IOS4 = 1;   // timer 4 output compare  TIE_C4I = 1;     // interrupt 4 enable    TSCR2_PR = 1;    // prescale 25Mhz/2 = 12 500 000 Hz  TC4 = 62500 ;    // 62500 counter: 12500000Hz/62500 = 200 Hz (5ms)    TSCR1_TSFRZ = 1;  TSCR1_TEN = 1;   // abilitazione timer }void timer4_isr_handler(void){   int_counter++;   if (int_counter % 200 == 0 )  LED1 = ~LED1; (1 second)      //here the functions   .......
 
   TFLG1_C4F = 1;
}

 

0 Kudos
Reply