Sign In

Don't have a Xilinx account yet?

  • Choose to receive important news and product information
  • Gain access to special content
  • Personalize your web experience on Xilinx.com

Create Account

Username

Password

Forgot your password?
XClose Panel
Xilinx Home
Reply
Super Contributor
rikusleroux
Posts: 123
Registered: ‎05-21-2009
0

PowerPC 440 context switching

Hi.

 

I'm struggeling with interrupts on a powerPC 440. How do I do context switching? What I want to do, is to just toggle a flag in the interrupt, but as soon as the interrupt is serviced and the flag is set, the main code is unable to see the state of the flag.

 

Thanks.

Super Contributor
dorau
Posts: 127
Registered: ‎08-29-2008
0

Re: PowerPC 440 context switching

Hi rikusleroux,

 

you have to ensure that the flag must not be registered but swapped into the data section like this:

 

static volatile int flag;

 

static void isr (void *p_attr){

  flag=TRUE;

  ..

}

 

void main(void){

  if(TRUE==flag){

    ..

  }

  ..

}

 

Rgds,

Kai

Super Contributor
rikusleroux
Posts: 123
Registered: ‎05-21-2009
0

Re: PowerPC 440 context switching

Thanks dorau.

 

So if I only put "static volatile" before my variable this will solve my problem? What if the flag is part of a struct? Should I make the whole struct "static volatile" of only the variable inside the struct? I should also mention that the struct is declared in another source file, so I'm using it as an "extern" variable. Will this make a difference?

Super Contributor
dorau
Posts: 127
Registered: ‎08-29-2008
0

Re: PowerPC 440 context switching

Hi,

 

>So if I only put "static volatile" before my variable this will solve my problem? What if the flag is part of a struct? Should I make the whole struct "static volatile" of only the variable inside the >struct? I should also mention that the struct is declared in another source file, so I'm using it as an "extern" variable. Will this make a difference?

 

The "static" keyword is not relevant. Using the keyword volatile is mandatory for global attributes that shall be processed in the ISR and main task in parallel to

avoid "race condition"!

If your flag is part of a struct, i guess you should use the volatile keyword, too.

 

To look how a context switch work try to examine the sources of the xilkernel multitask OS. There is a context switch implemented based on the PIT.

Rgds,

Kai