UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Explorer
Explorer
5,037 Views
Registered: ‎05-21-2009

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.

0 Kudos
3 Replies
Explorer
Explorer
5,029 Views
Registered: ‎08-29-2008

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

0 Kudos
Explorer
Explorer
5,024 Views
Registered: ‎05-21-2009

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?

0 Kudos
Explorer
Explorer
5,021 Views
Registered: ‎08-29-2008

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

0 Kudos