Code Warrior 5.0 Struct. Problem (Poland) PLEASE HELP !!!!!

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

Code Warrior 5.0 Struct. Problem (Poland) PLEASE HELP !!!!!

1,567 Views
SMX
Contributor I
Sorry for My English.
 
The system is connected thru rs232 with PC Computer. There is a program to save some settings to the device. And when I was using CW 4.6, 4.7 there was no problem at all. PC was connected to Device and read and save was ok.
 
BUT now when I have installed CW 5.0 There is a serious problem.
For example when I have Union in "C" and I have a struct on HCS12X side it looks like this below: 
But when I read it on PC side the struct is REVERSED (first bit of struct is the last one on PC Program) !!!!!!! 
 
When I'm using CW 4.7 there is no problem at all.  
 
volatile union
{
volatile struct
{
volatile unsigned int PkEm1 :1; //bits
volatile unsigned int PkEm2 :1; //
volatile unsigned int PkEm3 :1; //
volatile unsigned int PkEm4 :1; //
volatile unsigned int PkEm5 :1; //
volatile unsigned int PkEm6 :1; //
volatile unsigned int PkEm7 :1; //
volatile unsigned int PkEm8 :1; //

volatile unsigned int PrzekButlaRed :1; //
volatile unsigned int PrzekInjG :1; //
volatile unsigned int Stac :1; //
volatile unsigned int NORPM     :1;    //
volatile unsigned int Sleep :1; //
}bit;
volatile unsigned int ALL;
}HardStates;
 
Labels (1)
Tags (1)
0 Kudos
3 Replies

355 Views
kef
Specialist I

Bitfields and structs are not portable, so nothing strange you can't receive them on PC. However it's bit weird that CW5.0 has changed allocation order. I didn't try 5.0, but 4.6 header files are clearly least bit first. From MC9S12D64.H:

 

/*** PORTAB - Port AB Register; 0x00000000 ***/
typedef union {
  word Word;
   /* Overlapped registers: */
  struct {
    /*** PORTA - Port A Register; 0x00000000 ***/
    union {
      byte Byte;
      struct {
        byte BIT0        :1;                                       /* Port A Bit 0 */
        byte BIT1        :1;                                       /* Port A Bit 1 */
..

 

Could you verify if you have it the same or not in CW5.0 header files?

 

Pozdrawiam!

0 Kudos

355 Views
SMX
Contributor I

on the CW5.0 "mc9s12xdg128.h" :

 

/*** PORTAB - Port AB; 0x00000000 ***/

typedef union {

  word Word;

   /* Overlapped registers: */

  struct {

    /*** PORTA - Port A Register; 0x00000000 ***/

    union {

      byte Byte;

      struct {

        byte PA0         :1;                                       /* Port A Bit 0 */

        byte PA1         :1;                                       /* Port A Bit 1 */

        byte PA2         :1;                                       /* Port A Bit 2 */

        byte PA3         :1;                                       /* Port A Bit 3 */

        byte PA4         :1;                                       /* Port A Bit 4 */

        byte PA5         :1;                                       /* Port A Bit 5 */

        byte PA6         :1;                                       /* Port A Bit 6 */

        byte PA7         :1;                                       /* Port A Bit 7 */

      } Bits;

    } PORTASTR; 

0 Kudos

355 Views
stanish
NXP Employee
NXP Employee

Hi SMX,

 

I'm not aware of any changes in CodeWarrior v5.0 related to the bitfields.

I'd suggest you to doublecheck compiler settings. You might use different bitfield allocation in the projects (-BfaBxx option).

You can generate the list of predefined compiler macros "-Ldf=predef.h" to check compiler bitfield allocation options (e.g  __BITFIELD_LSBIT_FIRST__, __BITFIELD_MSBYTE_FIRST__, __BITFIELD_MSWORD_FIRST__, __BITFIELD_TYPE_SIZE_REDUCTION__...)

 

Stanish

0 Kudos