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"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 intwhy 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 interruptswhy? 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:
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 flagYou 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 interruptsThis 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> </DIV><DIV><FONT face=3DArial size=3D2>"Marcipicus" <</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>> 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>> I'm trying to get the timer =overflow interrupt=20working on the hc12 dp256b<BR>> but so far I haven't had any =luck.<BR>>=20<BR>> The overflow interrupt is never generated in my program(used a=20breakpiont<BR>> in isr) and I can't find the logic error in my =code.<BR>>=20<BR>> Here is my work environment:<BR>> =CHIP: =20hc12dp256<BR>> COMPILER: ICC12<BR>> DEBUGGER: NOICE<BR>> =<BR>>=20Here's the code that doesn't work<BR>> <BR>>=20-------------------------------------------------------------------------=-----<BR>>=20#include <hcs12dp256.h><BR>> #include <stdio.h><BR>> =<BR>>=20#pragma interrup_handler TOVF_ISR() (isrs installed in vector table=20file)<BR>> <BR>> int count<BR>> <BR>> void =main(void)<BR>>=20{<BR>> //setup<BR>> =20TFLG2|=3D0x80; //Clear interrupt=20flag</FONT></DIV><DIV><FONT face=3DArial color=3D#ff0000 size=3D2></FONT> </DIV><DIV><FONT face=3DArial color=3D#ff0000 size=3D2>You should only clear =the=20flag by TFLG2 =3D 0x80 else you will clear any other unserviced =flags as=20well. </FONT></DIV><DIV><BR><FONT face=3DArial size=3D2>> TSCR2=20=3D0x8D; //Set timer =frequency(250kHz), Enable=20TOVF int<BR>> =TSCR1|=3D0x90; //enable=20timer and fast clear TOC7<BR>> <BR>> =20asm("cli");<BR>> <BR>> count=3D0;<BR>> =20while(count<3){<BR>> if(i%2000=3D=3D0) =printf("count:=20%d\n",count);<BR>> i++;<BR>> }<BR>>=20<BR>> printf("count reached three\n");</FONT></DIV><DIV><FONT face=3DArial size=3D2></FONT> </DIV><DIV><FONT face=3DArial size=3D2><FONT color=3D#ff0000>Your returning =from=20Main!!!!!!!!!!</FONT></DIV><DIV><BR>> }<BR>> <BR>> void TOVF_ISR()<BR>> {<BR>> =asm("cli"); //reenable interrupts</FONT></DIV><DIV><FONT face=3DArial size=3D2></FONT> </DIV><DIV><FONT face=3DArial size=3D2><FONT color=3D#ff0000>This is not =needed, RTI will=20restore it</FONT></DIV><DIV><BR>> count++;<BR>> TFLG2|=3D0X80;</DIV><DIV> </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>> }<BR>>=20-------------------------------------------------------------------------=---<BR>>=20<BR>> Thanks to anyone who can help me out<BR>>=20<BR>></FONT></DIV></BODY></HTML>------=_NextPart_000_0195_01C9ADFE.4134FD60--
PhilW wrote:> > Part 1.1 Type: Plain Text (text/plain)> Encoding: quoted-printablePlease 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.
Before you can participate to the *related sites forums, you need to login orcreate an account.