Giovanni Zanettin

Flags in MCUinit.c

Discussion created by Giovanni Zanettin on Apr 1, 2010
Latest reply on Apr 28, 2010 by Mark Hotchkiss

Hello,

I have some problem with flags and variables (I use Codewarrior 5.9.0 with device MC9S08QG8). I created a project using Device Initialization and, enabling timer interrupts, in MCUinit.c I find the following lines :

 

/*

** ===================================================================

**     Interrupt handler : isrVtpmovf

**

**     Description :

**         User interrupt service routine.

**     Parameters  : None

**     Returns     : Nothing

** ===================================================================

*/

__interrupt void isrVtpmovf(void)

{

  /* Write your interrupt code here ... */

}

/* end of isrVtpmovf */

 

 

In main.c I defined some flags like this:

 

typedef union {

  byte Byte;

  struct {

    byte b0       :1;                                       /*  */

    byte b1       :1;                                       /*  */

    byte b2       :1;                                       /*  */

    byte b3       :1;                                       /*  */

    byte b4       :1;                                       /*  */

    byte b5       :1;                                       /*  */

    byte b6       :1;                                       /*  */

    byte b7       :1;                                       /*  */

  } Bits;

} flagstr;

extern volatile flagstr _flag;

#define flags                        _flag.Byte

#define f0                             _flag.Bits.b0

#define f1                             _flag.Bits.b1

#define f2                             _flag.Bits.b2

#define f3                             _flag.Bits.b3

#define f4                             _flag.Bits.b4

#define f5                             _flag.Bits.b5

#define f6                             _flag.Bits.b6

#define f7                             _flag.Bits.b7

 

 

When I use the byte “flags” or the single bits “f0”, “f1” … in main.c I have no problem, but I can’t use “flags” or “f0”, “f1” … in the interrupt handler isrVtpmovf. I tried using extern, volatile,  I always have error.

Can you help me? Thanks in advance!

Giovanni

Outcomes