cancel
Showing results for 
Search instead for 
Did you mean: 

CXSTM8 bug when writing to bit structure

wolfgang239955_stm1_st
Associate II
Posted on October 11, 2012 at 09:36

To optimize the code I put nearly all the flags to bit structures. Now I came across a  bug in the CXSTM8 when writing to bits. Reading bits doesn't bring any problem. 

The good news for me is that I found a workaround.

Here is the example:

/*----------------------------------------------------*/

typedef struct

{

  

int

    sem_on  :1; 

/* bit */

  

int

    sem_off :1; 

/* bit */

  

int

    sem_tog :1; 

/* bit */

} key_;

/*struct*/

key_ key_x;

/*struct*/

key_* key_down = &key_x;

&sharppragma

section

const

{}

/*struct*/

key_*

const

key_up = &key_x;

 void clear_key_updown(

void

)

{

/*struct*/

key_* p_key;

   key_down->sem_on = 0; 

/* variable pointer ..

   - ******** ERROR:  bad addressing mode  *********/

   (*key_down).sem_on = 0;

/* alternate expression ..

   - ******** ERROR:  bad addressing mode  *********/

   p_key = key_down;     

/* pointer substitution - o.k. */

   p_key->sem_on  = 0;

  

   key_up->sem_on   = 0;  

/* const pointer - o.k. */

   (*key_up).sem_on = 0;  

/* alternate expression - o.k. */

}

/*---------end of file------------------------------*/

The workaround you can see is to substitute the specific pointers.

 WoRo

#cxstm8 #cxstm8
2 REPLIES 2
luca239955_stm1_st
Senior II
Posted on October 11, 2012 at 10:46

Hi Woro,

we cannot recreate your problem here: please let me know the version and compiler options used (here or to my email: luca dot ubiali _at_ cosmic dot fr)

Regards,

Luca (Cosmic)

wolfgang239955_stm1_st
Associate II
Posted on October 12, 2012 at 08:30

Hi Luca,

thanks first for your well-known promt reply.

I'll append the list file to this posting.

The compiler command line is:

cxstm8 +mods0 +debug -pxp -no -pp -l -duC_MMI -dUART_SCI -iuc_mmi\include -iinclude $(ToolsetIncOpts) -cl$(IntermPath) -co$(IntermPath) $(InputFile)

Hope it will help solving the problem.

Best Regards,

WoRo

________________

Attachments :

cxstm8_bug_2012-10-11.ls : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzO9&d=%2Fa%2F0X0000000bL0%2FgFzizlQa6S.Qy6uZor1dKZlLOIqTkjO06F4CQ3MLCZc&asPdf=false