2 Replies Latest reply on Jan 25, 2017 11:58 PM by erho_1622121

    Shared data block





      I want to use a shared data block between different c-files.


      I'm using a 32 byte array, which I fill up with data from my I2C-bus in I2CHandler.c. The data will be displayed on a smart display. So, I try to send the data to the display in Display.c.


      Therefore, I defined the variable in vars.h as:


      static BYTE dataReceive[32];


      The vars.h file is included in I2CHandler.c and Display.c. But somehow Display.c will not have the same data (all zeros) as I2CHandler.c (some random hex-data).


      How can I fix this behavior?


      The data is received, because if I send the data to the display in I2CHandler.c, then the correct data is shown. But I want to separate the different functions in different files.


      Thanks in advance.




      With kind regards,





        • 1. Re: Shared data block

          Do not define data in .h files, only declarations allowed here. Declare data as "extern" and define the data in main.c





          • 2. Re: Shared data block



            thats what I did now. I give the pointer to the data to each module and then it is possible to access the data by different modules.


            But I thought it should be possible to share data declared in a e.g. General.h file. When defined as static, there should be only one declaration in memory.


            Compiling results in no errors and warnings. But the data is not the same over the different modules (looks like it is declared multiple times) ?!?!?