TIMER_ INTERRUPT gives me error while execution in MC9S12C64

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

TIMER_ INTERRUPT gives me error while execution in MC9S12C64

2,523 Views
AkellaANand
Contributor I
if have writen a code for the timer interrupt of MC9S12C64. The following is my code and while execution it gives me an error L1907:FIXup overflow in _Vector_8, to Timer_int type 1,at offset 0x0

And i want  15 sec delay and my bus clock is 4 Mhz and  prescalar is 128 then the value to be loaded in the int register is 0x7270E how to load this value into 8bit register. please help me.


#include <hidef.h>      /* common defines and macros */
#include <MC9S12C64.h>     /* derivative information */



#define TIMER_TO_CAPTURE TIOS
#define TIMER_COMPARE_FORCE CFORC
#define OUTPUT_COMPARE_MASKREG OC7M
#define OUTPUT_COMPARE_DATAREG OC7D
#define TIMER_COUNT_REG TIOS

#define TIMER_SYSTEM_CONTROL_REGISTER2 TSCR2

#define TIMER_FAST_FLAG_CLEAR TSCR1_TFFCA                    
#define TIMER_STOPS_FREEZE_MODE TSCR1_TSFRZ                   
#define TIMER_MODULE_STOP TSCR1_TSWAI                  
#define TIMER_ENABLE TSCR1_TEN    

#define Timer_Toggle_On_Overflow_Register1 TTOV
#define TIMER_CONTROL_REGISTER1 TCTL1 
#define TIMER_CONTROL_REGISTER2 TCTL2 

#define TIMER_CONTROL_REGISTER3 TCTL3
#define TIMER_CONTROL_REGISTER4 TCTL4
#define Timer_Interrupt_Enable_Register TIE
#define Timer_Overflow_Flag TFLG2_TOF

#define MAIN_TIMER_INTERRUPT_FLAG1 TFLG1
#define TIMER_OVERFLOW_FLAG TFLG2_TOF

#define SET 1
#define RESET 0

#define TIMERSET4MS 1600




void Timer_InterruptINT(void)
  {
     /* The corresponding  channel acts as an input capture */
     TIMER_TO_CAPTURE=0xFF;
    
     /*Timer  Compare force is set zero */
     // TIMER_COMPARE_FORCE=0xFF;
     
     /* Output compare mask register is set zero */ 
     //OUTPUT_COMPARE_MASKREG =0x00;
     
     /* Output compare DATA register is set zero */ 
     //OUTPUT_COMPARE_DATAREG=0x00;
     
     /* TIMER Count Register is of 2 BYTES of size*/     
  //     TIMER_COUNT_REGH=0x4E;
  //    TIMER_COUNT_REGL=0x20;
     
     
      /* if u want to enable the timer interrupt then set it*/
      TIMER_ENABLE=SET;
     /* Timer Module Stops While in Wait is set to zero*/
      TIMER_MODULE_STOP=RESET;
     /* Timer Stops While in Freeze Mode is set to zero*/
      TIMER_STOPS_FREEZE_MODE=RESET;
     /* Timer Fast Flag Clear All   is zero.
      * 0 means  Allows the timer flag clearing to function normally.    */
      TIMER_FAST_FLAG_CLEAR=RESET;
     
    //  Timer_Toggle_On_Overflow_Register1=0xFF; 
      
      TIMER_CONTROL_REGISTER1=0x00;
      TIMER_CONTROL_REGISTER2=0x00;
     
      Timer_Interrupt_Enable_Register=0x02;
      TIMER_SYSTEM_CONTROL_REGISTER2=0x01;
     
      /* Maint timer interrupt flag1 is used to check whether any error has occured*/
    
     TC0=TIMERSET4MS;
    
                       
   }
  
interrupt 8 void Timer_int(void)
 {
   
    PORTB_BIT0=~PORTB_BIT0;
    PORTB_BIT1=~PORTB_BIT1;
    TFLG1 = 0x02 ;
     
 }
 
   
 void PortInit(void)
 {
     /* Mode register config as Normal single chip*/
     MODE=0x80;
      
     // Port E Assignement Resgister (PEAR) Normal single chip
     PEAR=0x10;
      
     /* PLL clock init */
     /* Selecting the clock source as OSCCLK */
     CLKSEL &= 0x7f;
     /* Disable the PLL */
     PLLCTL &= 0xBF;
    
    
     /* Pull UP device enable */
     PERT=0xFF ;         
     /* default  configured as output */
     DDRAB=0xFF;
    
     DDRB=0xFF;
    
  }
 

void main(void)
{
    Timer_InterruptINT();
   
    PortInit();

    EnableInterrupts;
}

Labels (1)
0 Kudos
2 Replies

438 Views
Xzidax
Contributor I
Hi,
 
I think if you are learning you should not go that much complexity at first just for 15 sec delay.
 
You can use the below snippet,
 
In the function:
TSCR1 = 0x80;
TSCR2 = 0x07;
 
TCx = TCNT + 0x7270E; // i think bus clock 4 MHz
// Now disable all interrupts
__asm SEI;
 
Select respective channel in TIOS
Select respective interrupt in TIE
 
//Enable all interrupts
__asm CLI;
 
In Interrupt routine:
//Clear respective flag from TFLG1 without touching other flags
TCx = TCNT + 0x7270E;
 
--- > And enjoy 15 sec delay repeatedly.
Note: But you should follow the instructions of CompilerGuru also. Then only you can achieve it.
 
Regards
Xzidax
0 Kudos

438 Views
CompilerGuru
NXP Employee
NXP Employee
Just about the link time error, not about the actual content of your code.

Interrupt routines like the Timer_int have to be allocated non banked. E.g (untested)



Code:
#pragma push#pragma CODE_SEG __NEAR_SEG NON_BANKEDinterrupt 8 void Timer_int(void) {       PORTB_BIT0=~PORTB_BIT0;    PORTB_BIT1=~PORTB_BIT1;    TFLG1 = 0x02 ;      }#pragma pop

 

Daniel
0 Kudos