Movatterモバイル変換


[0]ホーム

URL:


EmbeddedRelated.com
Forums
The 2026 Embedded Online Conference
   Forums    More Forums   comp.arch.embedded  

68hc12 TOVF interrupt problems ICC12

Started byMarcipicusMarch 25, 2009
I'm trying to get the timer overflow interrupt working on the hc12 dp256bbut so far I haven't had any luck.The overflow interrupt is never generated in my program(used a breakpiontin isr) and I can't find the logic error in my code.Here is my work environment:CHIP:     hc12dp256COMPILER: ICC12DEBUGGER: NOICEHere'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 countvoid 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
Reply byOliver BetzMarch 25, 20092009-03-25
"Marcipicus" wrote:
>I'm trying to get the timer overflow interrupt working on the hc12 dp256b>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
why do you set TCRE?
> 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");>}
not what you asked, but what happens when main() returns?
>void TOVF_ISR()>{> asm("cli"); //reenable interrupts
why? RTI will do so, and your ISR doesn't run very long.
> count++;> TFLG2|=0X80;>}
Oliver-- Oliver Betz, Munichdespammed.com might be broken, use Reply-To:
Reply byPhilWMarch 25, 20092009-03-25
This is a multi-part message in MIME format.------=_NextPart_000_0195_01C9ADFE.4134FD60Content-Type: text/plain;charset="iso-8859-1"Content-Transfer-Encoding: quoted-printable"Marcipicus" <msammon@connect.carleton.ca> wrote in message =news:ffWdnayE0-NRq1fUnZ2dnUVZ_gOWnZ2d@giganews.com...
> I'm trying to get the timer overflow interrupt working on the hc12 =
dp256b
> but so far I haven't had any luck.>=20> 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.>=20> Here is my work environment:> CHIP: hc12dp256> COMPILER: ICC12> DEBUGGER: NOICE>=20> Here's the code that doesn't work>=20> =
-------------------------------------------------------------------------=-----
> #include <hcs12dp256.h>> #include <stdio.h>>=20> #pragma interrup_handler TOVF_ISR() (isrs installed in vector table =
file)
>=20> int count>=20> void main(void)> {> //setup> TFLG2|=3D0x80; //Clear interrupt flag
You should only clear the flag by TFLG2 =3D 0x80 else you will clear any =other unserviced flags as well.=20
> TSCR2 =3D0x8D; //Set timer frequency(250kHz), Enable TOVF int> TSCR1|=3D0x90; //enable timer and fast clear TOC7>=20> asm("cli");>=20> count=3D0;> while(count<3){> if(i%2000=3D=3D0) printf("count: %d\n",count);> i++;> }>=20> printf("count reached three\n");
Your returning from Main!!!!!!!!!!
> }>=20> void TOVF_ISR()> {> asm("cli"); //reenable interrupts
This is not needed, RTI will restore it
> count++;> TFLG2|=3D0X80;
Same as mentioned above, clear by TFLG2 =3D 0x80. However, you have =setup to auto clear (TSCR1 |=3D 0x90) which simply requires an access to =the TCNT registers to auto clear.
> }> =
-------------------------------------------------------------------------=---
>=20> Thanks to anyone who can help me out>=20>
------=_NextPart_000_0195_01C9ADFE.4134FD60Content-Type: text/html;charset="iso-8859-1"Content-Transfer-Encoding: quoted-printable<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><META http-equiv=3DContent-Type content=3D"text/html; =charset=3Diso-8859-1"><META content=3D"MSHTML 6.00.6000.16809" name=3DGENERATOR><STYLE></STYLE></HEAD><BODY><DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV><DIV><FONT face=3DArial size=3D2>"Marcipicus" &lt;</FONT><A=20href=3D"mailto:msammon@connect.carleton.ca"><FONT face=3DArial=20size=3D2>msammon@connect.carleton.ca</FONT></A><FONT face=3DArial =size=3D2>&gt; wrote=20in message </FONT><A=20href=3D"news:ffWdnayE0-NRq1fUnZ2dnUVZ_gOWnZ2d@giganews.com"><FONT =face=3DArial=20size=3D2>news:ffWdnayE0-NRq1fUnZ2dnUVZ_gOWnZ2d@giganews.com</FONT></A><FO=NT=20face=3DArial size=3D2>...</FONT></DIV><DIV><FONT face=3DArial size=3D2>&gt; I'm trying to get the timer =overflow interrupt=20working on the hc12 dp256b<BR>&gt; but so far I haven't had any =luck.<BR>&gt;=20<BR>&gt; The overflow interrupt is never generated in my program(used a=20breakpiont<BR>&gt; in isr) and I can't find the logic error in my =code.<BR>&gt;=20<BR>&gt; Here is my work environment:<BR>&gt; =CHIP:&nbsp;&nbsp;&nbsp;&nbsp;=20hc12dp256<BR>&gt; COMPILER: ICC12<BR>&gt; DEBUGGER: NOICE<BR>&gt; =<BR>&gt;=20Here's the code that doesn't work<BR>&gt; <BR>&gt;=20-------------------------------------------------------------------------=-----<BR>&gt;=20#include &lt;hcs12dp256.h&gt;<BR>&gt; #include &lt;stdio.h&gt;<BR>&gt; =<BR>&gt;=20#pragma interrup_handler TOVF_ISR() (isrs installed in vector table=20file)<BR>&gt; <BR>&gt; int count<BR>&gt; <BR>&gt; void =main(void)<BR>&gt;=20{<BR>&gt;&nbsp; //setup<BR>&gt;&nbsp;=20TFLG2|=3D0x80;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Clear interrupt=20flag</FONT></DIV><DIV><FONT face=3DArial color=3D#ff0000 size=3D2></FONT>&nbsp;</DIV><DIV><FONT face=3DArial color=3D#ff0000 size=3D2>You should only clear =the=20flag&nbsp;by TFLG2 =3D 0x80 else you will clear any other unserviced =flags as=20well.&nbsp;</FONT></DIV><DIV><BR><FONT face=3DArial size=3D2>&gt;&nbsp; TSCR2=20=3D0x8D;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Set timer =frequency(250kHz), Enable=20TOVF int<BR>&gt;&nbsp; =TSCR1|=3D0x90;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //enable=20timer and fast clear TOC7<BR>&gt; <BR>&gt;&nbsp;=20asm("cli");<BR>&gt;&nbsp;<BR>&gt;&nbsp; count=3D0;<BR>&gt;&nbsp;=20while(count&lt;3){<BR>&gt;&nbsp;&nbsp;&nbsp; if(i%2000=3D=3D0) =printf("count:=20%d\n",count);<BR>&gt;&nbsp;&nbsp;&nbsp; i++;<BR>&gt;&nbsp; }<BR>&gt;=20<BR>&gt;&nbsp; printf("count reached three\n");</FONT></DIV><DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV><DIV><FONT face=3DArial size=3D2><FONT color=3D#ff0000>Your returning =from=20Main!!!!!!!!!!</FONT></DIV><DIV><BR>&gt; }<BR>&gt; <BR>&gt; void TOVF_ISR()<BR>&gt; {<BR>&gt;&nbsp; =asm("cli");&nbsp;&nbsp;&nbsp; //reenable interrupts</FONT></DIV><DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV><DIV><FONT face=3DArial size=3D2><FONT color=3D#ff0000>This is not =needed, RTI will=20restore it</FONT></DIV><DIV><BR>&gt;&nbsp; count++;<BR>&gt;&nbsp; TFLG2|=3D0X80;</DIV><DIV>&nbsp;</DIV><DIV><FONT color=3D#ff0000>Same as mentioned above, clear by TFLG2 =3D =0x80.=20However, you have setup to auto clear (TSCR1 |=3D 0x90) which simply =requires an=20access to the TCNT registers to auto clear.</FONT></DIV><DIV><FONT color=3D#ff0000></FONT><BR>&gt; }<BR>&gt;=20-------------------------------------------------------------------------=---<BR>&gt;=20<BR>&gt; Thanks to anyone who can help me out<BR>&gt;=20<BR>&gt;</FONT></DIV></BODY></HTML>------=_NextPart_000_0195_01C9ADFE.4134FD60--
Reply byCBFalconerMarch 25, 20092009-03-25
PhilW wrote:
> > Part 1.1 Type: Plain Text (text/plain)> Encoding: quoted-printable
Please do not use html in Usenet. This is a pure text medium.-- [mail]: Chuck F (cbfalconer at maineline dot net) [page]: <http://cbfalconer.home.att.net> Try the download section.
The 2026 Embedded Online Conference

Sign in

Forgot username or password?  | Create account

Search forums

Free PDF Downloads

Introduction to Embedded Systems - A Cyber-Physical Systems Approach
Microcontroller Programming and Interfacing
Real-time Image Processing on Low Cost Embedded Computers

Blogs - Hall of Fame

So You Want To Be An Embedded Systems Developer

So You Want To Be AnEmbedded Systems Developer
Steve Branam

Introduction to Microcontrollers

Introduction toMicrocontrollers
Mike Silva

Important Programming Concepts (Even on Embedded Systems)

ImportantProgramming Concepts (Even on Embedded Systems)
Jason Sachs

How FPGAs Work and Why You'll Buy One

HowFPGAs Work and Why You'll Buy One
Yossi Krenin

MSP430 Launchpad Tutorial

MSP430 Launchpad Tutorial
Enrico Garante

Arduino Robotics

Arduino Robotics
Lonnie Honeycutt

Discussion Groups

Quick Links

About EmbeddedRelated.com

The Related Sites

Login

Before you can participate to the *related sites forums, you need to login orcreate an account.



Create free account |Forgot password?




I agree with theterms of use andprivacy policy.

Yes, I want to subscribe to your world famous newsletter and see for myself how great it is. I also understand that I can unsubscribe VERY easily!

[8]ページ先頭

©2009-2026 Movatter.jp