« Return to Thread: 68hc12 TOVF interrupt problems ICC12

Re: 68hc12 TOVF interrupt problems ICC12

by Edward Karpicz :: Rate this Message:

Reply to Author | View in Thread

Little addition

> void TOVF_ISR()
> {
>  asm("cli");    //reenable interrupts
>  count++;
>  TFLG2|=0X80;
> }

What happens ^^ here is

1) overlflow happens, overflow flag gets set
2) CPU stacks registers, sets I status bit, fetches TOVF vector and jumps to
ISR
3) asm("cli") is executed
4) single CPU instruction after cli is executed
5) since interrupt flag and interrupt mask are set, I status bit is cleared,
go back to step 2

On every overflow event, your ISR would execute more than once... Smart
code.

Edward


----- Original Message -----
From: "hendersonmarv" <hendersonmarv@...>
To: <68HC12@...>
Sent: Wednesday, March 25, 2009 4:31 PM
Subject: [68HC12] 68hc12 TOVF interrupt problems ICC12


> I'm trying to get the timer overflow interrupt working on the
> hc12dp256b but so far I haven't had any luck.
>
> The overflow interrupt is never generated in my program(used a breakpiont
> in isr) and I can't find the logic error in my code.
>
> Here is my work environment:
> CHIP:     hc12dp256
> COMPILER: ICC12
> DEBUGGER: NOICE
>
> Here's the code that doesn't work
>
> ----------------------------------------------------------------------
> #include <hcs12dp256.h>
> #include <stdio.h>
>
> #pragma interrup_handler TOVF_ISR() (isrs installed in vector table file)
>
> int count
>
> void main(void)
> {
>  //setup
>  TFLG2|=0x80;       //Clear interrupt flag
>  TSCR2 =0x8D;       //Set timer frequency(250kHz), Enable TOVF int
>  TSCR1|=0x90;       //enable timer and fast clear TOC7
>
>  asm("cli");
>
>  count=0;
>  while(count<3){
>    if(i%2000==0) printf("count: %d\n",count);
>    i++;
>  }
>
>  printf("count reached three\n");
> }
>
> void TOVF_ISR()
> {
>  asm("cli");    //reenable interrupts
>  count++;
>  TFLG2|=0X80;
> }
> ----------------------------------------------------------------------
>
> Thanks to anyone who can help me out
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>

 « Return to Thread: 68hc12 TOVF interrupt problems ICC12