about RTI,I need an example-urgent_MC13213

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

about RTI,I need an example-urgent_MC13213

1,821 Views
Beijing2008
Contributor I
Hi all:
I'm using MC13213 and CW6.1,Now I would like to generate a timer,trigger a timer interrupt per N*second.
how to use the RTI(real-time interrupt)? please give me an simple example!
 
thanks and best regards,
Charly
Labels (1)
0 Kudos
3 Replies

379 Views
bigmac
Specialist III
Hello Charly,
 
I will assume that you have set up the RTI module to generate an interrupt once per second.  Then your ISR might contain the following code -
 
if (tcounter) {
   tcounter--;
   if (!tcounter) {
      // Do timeout action here
   }
}
 
where tcounter is a global variable of a suitable size.  To commence a timeout period, set the value of tcounter to the number of seconds required.  If the action required on timeout is too time consuming to be included within the ISR, you would need to poll for the occurrence of timeout - simply test whether the global variable has reached a value of zero.
 
Regards,
Mac
 
0 Kudos

379 Views
Beijing2008
Contributor I
Hi bigmac :
  Thanks for your help!
  I'm sorry that the above description is not clear enough!
  It's sure that I don't konw how to set up the RTI module for generating a RTI interrupt,such as the SRTISC register or need other registers!
  The following code is a small test program,compiler under the CW6.1 and MC13213.
 
#include <hidef.h>
#include "derivative.h"
void Init_RTI(void)
{
 SRTISC=0xff;  //set up the SRTISC register,how to config it?
}
void Init_IO()
{
 PTDD_PTDD4 = 1; 
   PTDDD_PTDDD4=1; //output,for lighting a led
}
void main(void) {
  Init_RTI();
  Init_IO();
  EnableInterrupts;
  for( ; ; )  {
    __RESET_WATCHDOG();
  }    
 
}
interrupt VectorNumber_Vrti void RTI_ISR(void)  //RTI interrupt,but cann't be trigger here,WHY?
{
  if((SRTISC&0x80)==0x80){
   SRTISC_RTIACK=1;              //clear
   PTDD_PTDD4=~PTDD_PTDD4;  //on or off
  }
}
 
Running it,but the led was never lighted,I think the RTI module initializtion is wrong!
 
Please give me some hints!
Thanks again.
 
Best regards,
Charly
 


Message Edited by Beijing2008 on 2008-07-31 04:47 AM
0 Kudos

379 Views
bigmac
Specialist III
Hello Charly,
 
It is possible that you do not have the correct RTI clock source selected, and this will depend on the operating mode when RTI operation is required.  According to the datasheet, there are the following restrictions for the clock source -
 
Run mode - External reference clock only
Wait mode - External reference clock only
Stop3 - Either clock source
Stop2 - Internal RTI clock only
Stop1 - RTI inoperative
 
Assuming your tests use run mode, you will need to provide an external reference signal, and set the control bit SRTISC_RTICLKS.
 
Regards,
Mac
 
0 Kudos