Thread: Passing Struct through Array

  1. #1
    Registered User
    Join Date
    Mar 2013

    Passing Struct through Array

    I am trying to pass a struct through an array to another array from one microprocessor to another microprocessor and then dereference that array to update the same exact struct on the other microprocessor.

    My goal is to always have values inside of both structs while sending any updates to the struct on the other microprocessor in the mean time but I seem to be looping through the data and the members of the struct seem to be cleared out after every clock cycle. I can verify this by the flashing of my leds which the struct controls. I suspect it is how I am using the arrays but any input would be appreciated.

    extern struct i2c_data * TX_Data;
    extern struct i2c_data TX_Data_1;
    extern struct i2c_data TX_Data_2;
    unsigned char data_tmp[30];
            data_tmp[i] = *(((char*)&TX_Data) + i);
            data_tmp[i] = *(((char*)TX_Data) + i);
            SSP1BUF = data_tmp[i];
    struct i2c_data * TX_Data;
    struct i2c_data TX_Data_1;
    struct i2c_data TX_Data_2;
    unsigned char crap[4];
    static char y;
                            crap[y] =  SSPBUF;
                            TX_Data = (char *)&crap[y];
                            SSPCON1bits.CKP = 1;//Release clock

  2. #2
    Registered User
    Join Date
    Mar 2011
    sizeof(TX_Data) == 4. is that what you really want? and what does line 10 in the first example do? and why have both line 10 and line 11 writing to the same location in data_tmp?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 05-10-2012, 12:07 PM
  2. Replies: 32
    Last Post: 03-30-2011, 12:26 PM
  3. Replies: 1
    Last Post: 05-30-2009, 11:04 PM
  4. Passing array of struct as a function parameter
    By desmond5 in forum C Programming
    Replies: 5
    Last Post: 12-04-2007, 11:32 AM
  5. passing array of type struct to function
    By nappaji in forum C Programming
    Replies: 4
    Last Post: 05-02-2007, 05:13 PM

Tags for this Thread