Cast Byte array to long "occasionally" not working
I am casting a Byte array (results from ADC) to a long, but occasionally - about 1:100000, it get the sums wrong. I've got to the line in the code where it goes wrong, and it is when it is casting a byte array to a long (I use union Method).
//Signed ADC Value - so 24-bit value can be shifted in
union
{
uint8_t b[4];
int32_t l;
}I32ADCValue;
//Populate the Raw mV Array
for(i=0;i<8;i++)//Loop for each channel
{
I32ADCValue.b[3]=ads1298rData.ADCMsg.Channel[i][0];
I32ADCValue.b[2]=ads1298rData.ADCMsg.Channel[i][1];
I32ADCValue.b[1]=ads1298rData.ADCMsg.Channel[i][2];
I32ADCValue.b[0]=0;
//Channels are not in sequence - create temporary array here.
mVx[i]=(I32ADCValue.l*Gain_mV);
}
When I run the debugger, it is having too bit a blue in I32ADCValue.l - in fact where I set .b[0] to 0, it is not after it has cast it.....any clues?
