[En-Nut-Discussion] Hi resolution timer isr in assembler

en-nut-discussion-admin at egnite.de en-nut-discussion-admin at egnite.de
Mon Jun 23 02:10:20 CEST 2003


Hi Thorsten,

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:

SIGNAL(SIG_OUTPUT_COMPARE2)
{
static short    x       =   0;
static short    y       =   0;
static short    p       =   0;
static short    m       =   0xff;
static short    mask    =   1;
static short    bits;
  ...

If you want to use your poor layout structure, then you would have to 
define your variables as follows
SIGNAL(SIG_OUTPUT_COMPARE2)
{
static short x=0,static y=0, static p=0,static m=0xff;
static short mask=1,static bits;
  ...
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.

Hope this helps,
Peter S

Peter Scandrett
Engineering Systems Department
ALSTOM Australia Limited
3 Bridge Street, Pymble, 2073, Australia
Phone (+612) 94 88 49 11
Fax (+612) 94 88 49 00
peter.scandrett at transport.alstom.com




en-nut-discussion-admin at egnite.de
22-06-2003 09:50 pm
Please respond to en-nut-discussion

 
        To:     <en-nut-discussion at egnite.de>
        cc:     (bcc: Peter Scandrett/AUMIL01/Transport/ALSTOM)
        Subject:        Re: [En-Nut-Discussion] Hi resolution timer isr in assembler


Hi Stephen.

Thanks for that hint. It works for C ISRs, I didn't try assembler for now.
But now I have another problem. It seems that the ISR forgets some of its
local variables. I defined them using

SIGNAL(SIG_OUTPUT_COMPARE2)
{
  static short x=0,y=0,p=0,m=0xff;
  static short mask=1,bits;
  ...

but e.g. the variable p forgets its content.

Why?

bye
Thorsten


----- Original Message -----
From: <en-nut-discussion-admin at egnite.de>
To: <en-nut-discussion at egnite.de>
Sent: Saturday, June 21, 2003 8:47 PM
Subject: Re: [En-Nut-Discussion] Hi resolution timer isr in assembler


> Hi Thorsten;
>
> This the exact same situation I ran into, although I stuck with C.
>
> First I setup the timer:
>
>  // set timer 2 to CTC mode, clock / 256 = 16uS
>  TCCR2 = BV(WGM21) | BV(CS22);
>  // Set output compare register to 30 = 480uS for now
>  OCR2 = 30;
>  // enable the output compare match interrupt
>  TIMSK |= BV(OCIE2);
>
> Then using AVR GCC, I setup the interrupt routine as :
>
> SIGNAL(SIG_OUTPUT_COMPARE2)
> {
>  // code here
> }
>
> As for then calling the assembly routine, I think a function call in the
> SIGNAL routine will work, although it has the extra indirection in 
there.
>
> Cheers
>
> Stephen Noftall
>
> ----- Original Message -----
> From: <en-nut-discussion-admin at egnite.de>
> To: <en-nut-discussion at egnite.de>
> Sent: Saturday, June 21, 2003 11:20 AM
> Subject: [En-Nut-Discussion] Hi resolution timer isr in assembler
>
>
> > Hi,
> >
> > for multiplexing a big LED panel I need a fast timer ISR that does 
that
> > task. I have written one in assembler but don't know how to hook it 
into
> the
> > main C program. Maybe someone has an example how to insert assembler
code
> > into C and how to hook it to the timer IRQ. There should be a
possibility
> to
> > use a 4kB array of characters defined in the C program with that
assembler
> > code or vice versa.
> >
> > Thank you
> > Thorsten
> >
> >
> > _______________________________________________
> > En-Nut-Discussion mailing list
> > En-Nut-Discussion at egnite.de
> > http://www.egnite.de/mailman/listinfo/en-nut-discussion
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo/en-nut-discussion
>

_______________________________________________
En-Nut-Discussion mailing list
En-Nut-Discussion at egnite.de
http://www.egnite.de/mailman/listinfo/en-nut-discussion


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.egnite.de/pipermail/en-nut-discussion/attachments/20030623/c925be75/attachment.html>


More information about the En-Nut-Discussion mailing list