Sign in

username:

password:



Not a member?

Search 68hc12



Search tips

Subscribe to 68hc12



68hc12 by Keywords

68HC1 | 812A4 | 9S12DP256 | Bootloader | CodeWarrior | D60A | Debugger | DP256 | ECT | EEPROM | EVB | Flash | HC1 | HCS12 | I2C | IAR | ICC1 | Interrupts | LCD | M68KIT912DP256 | MC9S12DP256 | MC9S12DP256B | Metrowerks | Motor | MSCAN | Multilink | PLL | Quadrature | SDI | SPI | Transceiver | XFC

Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | 68HC12 | 68hc12 TOVF interrupt problems ICC12


Advertise Here

Join our technical discussions about Freescale Microcontrollers: M68HC12. (Freescale Semiconductor is a Subsidiary of Motorola).

68hc12 TOVF interrupt problems ICC12 - hendersonmarv - Mar 25 10:31:58 2009

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
#include

#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

------------------------------------



(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )


Re: 68hc12 TOVF interrupt problems ICC12 - Arlin L Pierce - Mar 25 12:10:04 2009

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"
Sent by: 6...@yahoogroups.com
03/25/2009 07:33 AM
Please respond to
6...@yahoogroups.com
To
6...@yahoogroups.com
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
#include

#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]

------------------------------------



(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: 68hc12 TOVF interrupt problems ICC12 - Michael Huslig - Mar 25 12:12:10 2009

I am not familiar with ICC12, but for a basic try:

1) Don't enable TCRE in TSCR1

2) Remove the cli in the interrupt routine.

3) Clear the interrupt flag with TFLG2=0x80.
----- Original Message -----
From: "hendersonmarv"
To: <6...@yahoogroups.com>
Sent: Wednesday, March 25, 2009 9:31 AM
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
#include

#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

------------------------------------

______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: 68hc12 TOVF interrupt problems ICC12 - Edward Karpicz - Mar 25 13:49:24 2009

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"
To: <6...@yahoogroups.com>
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
> #include #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
>
> ------------------------------------



(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: 68hc12 TOVF interrupt problems ICC12 - hendersonmarv - Mar 25 13:51:15 2009

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 6...@yahoogroups.com, Arlin L Pierce 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"
> Sent by: 6...@yahoogroups.com
> 03/25/2009 07:33 AM
> Please respond to
> 6...@yahoogroups.com
> To
> 6...@yahoogroups.com
> 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
> #include #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]
>

------------------------------------



(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )