« Return to Thread: 68hc12 TOVF interrupt problems ICC12

Re: 68hc12 TOVF interrupt problems ICC12

by hendersonmarv :: Rate this Message:

Reply to Author | View in Thread

Thanks a ton, the fast clear and TCRE were for an output compare I'm adding to this to generate a 1Hz interrupt on an output compare
channel. So I guess I just have to wait until the overflows happen
then set up the output compare.

For anybody who has the same problem I'm going to post the changes to the thread.

1. asm("cli") is not needed in isrs for ICC12

2. New Code changes
--------------------------------------------------------------------
        //setup changes
        TFLG2 = 0X80; //Clear interrupt flag
        TSCR2 = 0X85; //Set timer frequency:250KhZ ,
                                //and ENABLE TOVF int
        TSCR1 = 0X80; //enable timer
        asm("cli");

ISR CHANGES
void TOVF_ISR()
{
   count++;
   TFLG2 =0X80;
}

--- In 68HC12@..., Arlin L Pierce <alpierce@...> wrote:

>
> A couple of things to check:
>
> I don't think that the TCRE bit in TSCR2 should be set since you are not
> using the TC7 counter.
> Since TC7 resets to zero I'm not sure what will happen. Probably the TCNT
> counter will never overflow because
> it's being reset by the TC7 compare.
>
> For reference you don't need to use  TFLG2 |= 0x80. TFLG2 = 0x80 will work
> fine.
> Also interrupt handlers usually reenable interrupts automatically using an
> RTI instruction.
> I'm not familiar with ICC12 so this may not be true.
> I know for IAR compilers the function is prefaced by the keyword
> __interrupt to indicate the function should use RTI instead of RTS.
> However when your interrupt handler is used somewhere the RTI instruction
> must be called when it is finished.
> You should never need to do an asm("cli") instruction in an interrupt
> handler.
> Lastly I don't use the fast clear bit TFFCA in TSCR1. Since you reset it
> with TFLG2 = 0x80 it's not needed. Plus you not accessing TC7 anyway.
> If  ICC12 has a mixed listing output, see what instructions are generated.
>
> Good luck.
>
> Arlin L. Pierce
> Principal Software Engineer
> Raytheon Company / Rancho Innovations
>
>
>
>
> "hendersonmarv" <hendersonmarv@...>
> Sent by: 68HC12@...
> 03/25/2009 07:33 AM
> Please respond to
> 68HC12@...
>
>
> To
> 68HC12@...
> cc
>
> 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
>
>
>
>
>
>
> [Non-text portions of this message have been removed]
>


 « Return to Thread: 68hc12 TOVF interrupt problems ICC12