<br><font size=2 face="sans-serif">Hi Thorsten,<br>
</font>
<br><font size=2 face="sans-serif">I'm not too sure about the C specification, but I believe only the first variable is declared "static short". All the rest are declared "short". To solve your problem I believe the code should be as follows:<br>
</font>
<br><font size=2 face="Courier New">SIGNAL(SIG_OUTPUT_COMPARE2)<br>
{<br>
static short    x       =   0;</font>
<br><font size=2 face="Courier New">static short    y       =   0;</font>
<br><font size=2 face="Courier New">static short    p       =   0;</font>
<br><font size=2 face="Courier New">static short    m       =   0xff;<br>
static short    mask    =   1;</font>
<br><font size=2 face="Courier New">static short    bits;<br>
  ...</font>
<br>
<br><font size=2 face="sans-serif">If you want to use your poor layout structure, then you would have to define your variables as follows</font>
<br><font size=2 face="Courier New">SIGNAL(SIG_OUTPUT_COMPARE2)<br>
{<br>
static short x=0,static y=0, static p=0,static m=0xff;<br>
static short mask=1,static bits;<br>
  ...<br>
</font><font size=2 face="sans-serif">which I find very cluttered and difficult to understand. I know it is allowable in the C standard, but I consider it bad practice, for the reasons you just found out. In future define each variable on a line of it's own; it's clearer.</font>
<br>
<br><font size=2 face="sans-serif">Hope this helps,</font>
<br><font size=2 face="sans-serif">Peter S<br>
<br>
Peter Scandrett<br>
Engineering Systems Department<br>
ALSTOM Australia Limited<br>
3 Bridge Street, Pymble, 2073, Australia<br>
Phone (+612) 94 88 49 11<br>
Fax (+612) 94 88 49 00<br>
peter.scandrett@transport.alstom.com</font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td>
<td><font size=1 face="sans-serif"><b>en-nut-discussion-admin@egnite.de</b></font>
<p><font size=1 face="sans-serif">22-06-2003 09:50 pm</font>
<br><font size=1 face="sans-serif">Please respond to en-nut-discussion</font>
<br>
<td><font size=1 face="Arial">        </font>
<br><font size=1 face="sans-serif">        To:        <en-nut-discussion@egnite.de></font>
<br><font size=1 face="sans-serif">        cc:        (bcc: Peter Scandrett/AUMIL01/Transport/ALSTOM)</font>
<br><font size=1 face="sans-serif">        Subject:        Re: [En-Nut-Discussion] Hi resolution timer isr in assembler</font></table>
<br>
<br>
<br><font size=2 face="Courier New">Hi Stephen.<br>
<br>
Thanks for that hint. It works for C ISRs, I didn't try assembler for now.<br>
But now I have another problem. It seems that the ISR forgets some of its<br>
local variables. I defined them using<br>
<br>
SIGNAL(SIG_OUTPUT_COMPARE2)<br>
{<br>
  static short x=0,y=0,p=0,m=0xff;<br>
  static short mask=1,bits;<br>
  ...<br>
<br>
but e.g. the variable p forgets its content.<br>
<br>
Why?<br>
<br>
bye<br>
Thorsten<br>
<br>
<br>
----- Original Message -----<br>
From: <en-nut-discussion-admin@egnite.de><br>
To: <en-nut-discussion@egnite.de><br>
Sent: Saturday, June 21, 2003 8:47 PM<br>
Subject: Re: [En-Nut-Discussion] Hi resolution timer isr in assembler<br>
<br>
<br>
> Hi Thorsten;<br>
><br>
> This the exact same situation I ran into, although I stuck with C.<br>
><br>
> First I setup the timer:<br>
><br>
>  // set timer 2 to CTC mode, clock / 256 = 16uS<br>
>  TCCR2 = BV(WGM21) | BV(CS22);<br>
>  // Set output compare register to 30 = 480uS for now<br>
>  OCR2 = 30;<br>
>  // enable the output compare match interrupt<br>
>  TIMSK |= BV(OCIE2);<br>
><br>
> Then using AVR GCC, I setup the interrupt routine as :<br>
><br>
> SIGNAL(SIG_OUTPUT_COMPARE2)<br>
> {<br>
>  // code here<br>
> }<br>
><br>
> As for then calling the assembly routine, I think a function call in the<br>
> SIGNAL routine will work, although it has the extra indirection in there.<br>
><br>
> Cheers<br>
><br>
> Stephen Noftall<br>
><br>
> ----- Original Message -----<br>
> From: <en-nut-discussion-admin@egnite.de><br>
> To: <en-nut-discussion@egnite.de><br>
> Sent: Saturday, June 21, 2003 11:20 AM<br>
> Subject: [En-Nut-Discussion] Hi resolution timer isr in assembler<br>
><br>
><br>
> > Hi,<br>
> ><br>
> > for multiplexing a big LED panel I need a fast timer ISR that does that<br>
> > task. I have written one in assembler but don't know how to hook it into<br>
> the<br>
> > main C program. Maybe someone has an example how to insert assembler<br>
code<br>
> > into C and how to hook it to the timer IRQ. There should be a<br>
possibility<br>
> to<br>
> > use a 4kB array of characters defined in the C program with that<br>
assembler<br>
> > code or vice versa.<br>
> ><br>
> > Thank you<br>
> > Thorsten<br>
> ><br>
> ><br>
> > _______________________________________________<br>
> > En-Nut-Discussion mailing list<br>
> > En-Nut-Discussion@egnite.de<br>
> > http://www.egnite.de/mailman/listinfo/en-nut-discussion<br>
></font>
<br><font size=2 face="Courier New">> _______________________________________________<br>
> En-Nut-Discussion mailing list<br>
> En-Nut-Discussion@egnite.de<br>
> http://www.egnite.de/mailman/listinfo/en-nut-discussion<br>
><br>
<br>
_______________________________________________<br>
En-Nut-Discussion mailing list<br>
En-Nut-Discussion@egnite.de<br>
http://www.egnite.de/mailman/listinfo/en-nut-discussion<br>
</font>
<br>
<br>