[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Function Pointers on AT90USB1287 and ATmega2561

From: Peter LaDow
Subject: Re: [avr-gcc-list] Function Pointers on AT90USB1287 and ATmega2561
Date: Fri, 22 Feb 2008 14:25:22 -0800
User-agent: Thunderbird (Windows/20071031)

Kasper Pedersen wrote:
 > unsigned char how_long_is_the_instruction_pointer(void)
> {
>  unsigned sp1=SP;  unsigned sp2; //store stack ptr
>    asm volatile("call rrrtt\r\n rrrtt:\r\n"::);  //move stack ptr by
> calling
>   sp2=SP; cli(); SP=sp1; sei(); //restore stack
>  return sp1-sp2;
> }
> Result on USB1286 date code 0622 is 2
> Result on USB1287 date code 0548 is also 2.

My USB1287 (I don't know the date code) results in 2 as well.

And I did some more exploration.  And I found the problem.  When reading
the AT90SUSB1287 datasheet, and seeing that SP "is decremented by three
when the return address is pushed onto the Stack with subroutine call or
interrupt" made me try pushing a 3 byte PC onto the stack.

But it turns out I was stupid.  When creating the stack, RAMPZ was not
being pushed onto the stack, but when a context switch occurs, it
attempts to restore RAMPZ.  I had screwed-up some #includes (and thereby
losing some #defines) that pushed RAMPZ onto the stack.

So yes, the USB1287 does have a 2 byte PC.  And it does push/pop 2 byte
PC's.  As we expect it should.

So this issue is dead.  Sorry to waste everybody's time.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]