How to set XGISP31 and XGISP74

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to set XGISP31 and XGISP74

630 Views
zy
Contributor I

   In document MC9S12XEP100, I learned when initial XGATE ,I must initial XGISP31, XGISP74, and XGVBR registers. About  XGISP31 and  XGISP74, I don't understand if I must allocate two stacks for each channel thread? like that

      

//in .prm file

SEGMENTS
STACKRAM31  =READ_WRITE   0x3FC0 TO 0x3FDF ALIGN 2[1;1];
STACKRAM74  = READ_WRITE  0x3FE0 TO 0x3FFF ALIGN 2[1;1];

END

PLACEMENT
STACK31 INTO STACKRAM31;
STACK74 INTO STACKRAM74;

END
//in .c file
#pragma DATA_SEG STACK31
byte stackPoint31[32];
#pragma DATA_SEG STACK74
byte stackPoint74[32];

 

XGISPSEL=0x01;
XGISP31=(word)&stackPoint31;
XGISPSEL=0x02;
XGISP74=(word)&stackPoint74;
XGISPSEL=0x00;
XGVBR= (unsigned int)(void*__far)(XGATE_VectorTable - XGATE_VECTOR_OFFSET);

 

I understand, right?

Labels (1)
0 Kudos
4 Replies

429 Views
kef
Specialist I

Not at all. Did you try to create new multicore, processor expert -less project? Project wizard creates working code. There are some differences between it and yours. First diff is that demo project converts pointer first to far (global) pointer, before assigning it to XGISPxx:

 

  XGISP31= (unsigned int)(void*__far)(XGATE_STACK_L + 1);

 

This is important step, because XGATE addresses are similar to global memory addresses, except that GPAGE part of address is ignored. Without conversion CPU12X friendly pointer will be not understood by XGATE.

   

Another problem is that you are taking least address of stack memory. You should take address, which is above your stack space. So you should change it to

 

XGISP31=(word)((void * __far)&stackPoint31) +sizeof(stackPoint31);

 

There is no need to have two separate segment records for different stacks, the only requirements are that segment should be XGATE - accessible, and that word alignment is applied to all objects allocated there.

 

  

If you restrict your XGATE threads priorities either to 1-3 or to 4-7, you may allocate and initialize only one XGATE stack. Other stack won't be used.

Another option, which is compatible with older S12XD, which didn't have XGISPxx registers, is to make compiler initializing XGATE SP. XGATE compiler has option for this in Code Generation tab. You may set Initialize Stack option to XGATE address of top of stack.

0 Kudos

429 Views
zy
Contributor I

   I have created a project for MC9S12XEG128 witch CW for HC12 V4.6, but I didn't find it had any diffrent from the project for MC9S12XDG128, I really want a example project, if it is my IDE's problem?

0 Kudos

429 Views
kef
Specialist I

It must be your older CW. See attached updated empty new project.

 

Though you shouldn't follow it strictly. XGATE stacks are allocated there quite odd way. To get address above stack area, they define two memory segments for single stack. Two segments for one stack, and two segments for another one

 

      RAM_XGATE_STK_L_ = NO_INIT  DATA_FAR           0xFD1000 TO 0xFD107D;

      RAM_XGATE_STK_L = NO_INIT   DATA_FAR           0xFD107E TO 0xFD107F;

 

      RAM_XGATE_STK_H_ = NO_INIT  DATA_FAR           0xFD1080 TO 0xFD10FD;

      RAM_XGATE_STK_H = NO_INIT   DATA_FAR           0xFD10FE TO 0xFD10FF;  

   

placement records

      XGATE_STK_L       INTO  RAM_XGATE_STK_L;

 

      XGATE_STK_H       INTO  RAM_XGATE_STK_H;

 

 Now in the code they take address of RAM_XGATE_STK_L (without underscore symbol at the end :smileyhappy: and advance pointer  (+1) to point to location above this XGATE_STK_L:

 

  XGISP31= (unsigned int)(void*__far)(XGATE_STACK_L + 1);

 

This is quite funny. One segment is more than enough. It is better to allocate some array like you did in RAM, take pointer to it, convert to integer and add sizeof of your stack array.

0 Kudos

429 Views
zy
Contributor I

    I created a new project with CW for hc12 V5.1 ,and got a poject exactly same as you gived me . Thank you verymuch!

0 Kudos