4 Replies Latest reply on Mar 19, 2013 4:17 AM by user_14586677

    Global variables not getting initialized or may be  corrupted

    rocky.marciano

       Hi,

         

      I am using a global variable x, declaring it in some c1 file. This c1 file has an  interrupt code. x is altered on interrupt.

         

      Now in some  c2 file i am using this x

         

      extern x ;

         

      But the x is never seen altered in C2 even it is being altered in C1 file when interrupt comes.

         

      I have used OCD  to verify this.

         

      Now if i put the entire C1 file code into c2 file to avoid this extern, it works fine. 

         

      What is the scope and lifetime  of global variable?

         

      How do i communicate between files.

         

      I spent a whole day on this crap.