HCS12 MC9S12E128 Interrupt Problem

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

HCS12 MC9S12E128 Interrupt Problem

2,754 次查看
Deadstar
Contributor I
Hey guys,

I have been working using the C32 varient of the HCS12 OK and am quite comfortable with it. I have recently started using a E128 varient to take advantage of the I2C module but have been having trouble getting simple interrupts to work. As far as I can tell my code is fine.

Code:
#include <hidef.h>      /* common defines and macros */#include <mc9s12e128.h>     /* derivative information *//* Interrupt for TIM0_TC4 */void interrupt 12 timer0TC4(void) {  TIM0_TC4 += 512;  PTT ^= 0xFF;        /* Toggle LEDS */  TIM0_TFLG1_C4F = 1; /* Reset flag */ }void main(void) {  DDRT = 0xFF;  PTT = 0x00;    TIM0_TCTL1 = 0x00;    /* Take no action */  TIM0_TSCR1 = 0x80;    /* Enable counter */  TIM0_TSCR2 = 0x00;    /* No overlow flag/prescale */  TIM0_TIOS_IOS4 = 1;   /* Enable O/C Timer1 */    TIM0_TFLG1_C4F = 1;   /* Reset C4F flag */  TIM0_TIE = 0x10;      /* Enable interrupt on TC1 */    asm("SWI");  TIM0_TC4 = TIM0_TCNT + 512; /* Set value to interrupt */    for(;;) {}  }

 Does anyone see anything not right?

I am using code warrior, and using the simulation it appears my TCNT isnt even counting - probably the cause of nothing working.

Thanks again.

Colin



Message Edited by Deadstar on 2008-03-09 04:57 PM
标签 (1)
0 项奖励
回复
3 回复数

940 次查看
JimDon
Senior Contributor III
 asm("SWI"); // ???? Software interrupt?

Didn't you mean enable interrupts?
asm("CLI");

0 项奖励
回复

940 次查看
Deadstar
Contributor I
Sorry, I was tried when I posted and edited it wrong.

I am actually using   EnableInterrupts; instead but still no joy...

My title is a bit misleading - it is really a timer problem. I have been able to use a
RTI successfully so it is just the timers that are the problem.

I had no problem getting all the timers on the mc9s12c32 working so I am not sure why this is proving so hard.

Colin
0 项奖励
回复

940 次查看
J2MEJediMaster
Specialist I
One thing that comes to mind is the check the vector tables in mc9s12c32.h and mc9s12e128.h just to make sure you're working with the timer channel that you think you are.

The other thing I noticed while experimenting with the tools is that for the MC9S12C32, the memory model the CW wizard generated was small, while the memory model the CW wizard generated for the MC9S12E128 was banked. If you're using banked memory, you need to ensure that your interrupt lands in non-banked memory by bracketing its code with:

#pragma CODE_SEG __NEAR_SEG NON_BANKED

...isr code...

#pragma CODE SEG_DEFAULT

Just a thought.

---Tom
0 项奖励
回复