timer overflow interrupt

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

timer overflow interrupt

3,513 Views
Wind
Contributor I
hi,
 
I am using MC9s12NE64. I write a simple timer interrupt and increment a counter in the interrupt rountine.
I can't even get the interrupt to work. I have been trying to read up but I can't find why this simple program doesn't work.
 
in main.c
 
Code:
#include <hidef.h>      /* common defines and macros */#include <MC9S12NE64.h>     /* derivative information */#pragma LINK_INFO DERIVATIVE "1"volatile unsigned int count;void main(void) {  /* put your own code here */   TSCR1=0X80;//enable timer   TSCR2=0x85;  //select prescler bus clock/32  TFLG2=0x80;// clear timer flag   EnableInterrupts;   for(;;)   {    } /* wait forever */}#pragma CODE_SEG NON_BANKEDinterrupt void _Timerovf(void) { TFLG2 = 0x80;// clear the interrupt flag   count++; //increment counter   }   #pragma CODE_SEG DEFAULT

 
in the .prm file
 
Code:
/* This is a linker parameter file for the MC9S12NE64 */NAMES END /* CodeWarrior will pass all the needed files to the linker by command line. But here you may add your own files too. */SEGMENTS  /* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */    RAM = READ_WRITE 0x0400 TO 0x1FFF;    /* unbanked FLASH ROM */    ROM_4000 = READ_ONLY  0x4000 TO 0x7FFF;    ROM_C000 = READ_ONLY  0xC000 TO 0xF77F;    /* banked FLASH ROM */    PAGE_3C = READ_ONLY  0x3C8000 TO 0x3CBFFF;    PAGE_3D = READ_ONLY  0x3D8000 TO 0x3DBFFF;/*  PAGE_3E = READ_ONLY  0x3E8000 TO 0x3EBFFF; not used: equivalent to ROM_4000 *//*  PAGE_3F = READ_ONLY  0x3F8000 TO 0x3FBFFF; not used: equivalent to ROM_C000 */ENDPLACEMENT  /* Here all predefined and user segments are placed into the SEGMENTS defined above. */    _PRESTART,                   /* Used in HIWARE format: jump to _Startup at the code start */    STARTUP,                     /* startup data structures */    ROM_VAR,                     /* constant variables */    STRINGS,                     /* string literals */    VIRTUAL_TABLE_SEGMENT,       /* C++ virtual table segment */    NON_BANKED,                  /* runtime routines which must not be banked */    COPY                         /* copy down information: how to initialize variables */                                 /* in case you want to use ROM_4000 here as well, make sure                                    that all files (incl. library files) are compiled with the                                    option: -OnB=b */                                 INTO  ROM_C000/*, ROM_4000*/;    DEFAULT_ROM                  INTO  PAGE_3D, PAGE_3C;    DEFAULT_RAM                  INTO  RAM;ENDSTACKSIZE 0x100VECTOR 0 _Startup /* Reset vector: this is the default entry point for a C/C++ application. *///VECTOR 0 Entry  /* Reset vector: this is the default entry point for an Assembly application. *///INIT Entry      /* For assembly applications: that this is as well the initialisation entry point */VECTOR 16 _Timerovf/*timer overflow interrupt*/

 I attached the program with this forum.
 
Labels (1)
0 Kudos
3 Replies

505 Views
Wind
Contributor I

I read the forum in the following address

http://forums.freescale.com/freescale/board/message?board.id=16BITCOMM&message.id=204&query.id=3355#...

I take the timer overflow part from the above forum and put in my program and I used vector.c rather than the .prm for vector table.

but the interrupt still doesn't work.

0 Kudos

505 Views
Wind
Contributor I
sorry. I just test it out . The interrupt occur in the demo board but not in simulator. The main timer TCNT actually doesn't run. Any setting in simulator to make the timer TCNT runs?
0 Kudos

505 Views
Alban
Senior Contributor II

Dear Members

For TCNT in Simulator mode, please reply to new dedicated thread Wind Created

http://forums.freescale.com/freescale/board/message?board.id=16BITCOMM&message.id=1930

Not to this thread.
This is to avoid double discussions in parallel.

Cheers,
Alban - Mod

0 Kudos