SPI timing issues

I am interfacing Domino with an IMU I have (ADIS16350) with the initialization string below:

SPI.Configuration imuConfig = new SPI.Configuration((Cpu.Pin)ChipSelect_Port, false, 1, 1, true, true, 300, SPI.SPI_module.SPI1);

However the data I am tapping out doesn’t make sense at all… using the following code


        public void getData(double[] data)
        {
            inBuffer = new ushort[5];
            outBuffer = new ushort[5];
            outBuffer[0] = (ushort)(READ | XACCL_OUT);
            outBuffer[1] = (ushort)(READ | XGYRO_OUT);
            outBuffer[2] = (ushort)(READ | YGYRO_OUT);
            outBuffer[3] = (ushort)(READ | YACCL_OUT);
            outBuffer[4] = (ushort)(READ | ZACCL_OUT);
            pSPI.WriteRead(outBuffer, inBuffer);

            try
            {
                // output with conversion values
                data[0] = convert14toshort(inBuffer[0]) * 0.07326;    // °/s   xgyro
                data[1] = convert14toshort(inBuffer[1]) * 0.07326;    // °/s  ygyro
                data[2] = convert14toshort(inBuffer[2]) * 2.522;	  // mg xaccl
                data[3] = convert14toshort(inBuffer[3]) * 2.522;	  // mg yaccl
                data[4] = convert14toshort(inBuffer[4]) * 2.522;	  // mg zaccl
            }
            catch (IndexOutOfRangeException)
            {
                Debug.Print("Array too small");
            }
            finally
            {
                outBuffer = null;
                inBuffer = null;
            }
        }

I am suspecting the configuration string that is having problems. Would someone try to verify it and suggest a few improvements?

Thanks.

The configurations look OK. Try a slower clock. I see in accepts as low as 10KHz.
Do you have a digital analyzer to trace whats going on?

i get an invalidoperationexception error when i set to 10kHz

now running at about 200kHz

Ahh I found out my issue… Since the imu outputs a 14 bit data in a 16bit data frame, I was assuming the two MSBs are zero, as it was the case on my previous microcontroller. However bit 15 is set to 1 for some reasons, so I have to AND it out.

if first or last but is wrong then your data is shifted by one bit and this is usually the cause of nbot setting the clock correctly.

Update: This works…

 
        public void getData(double[] data)
        {
            inBuffer = new ushort[6];
            outBuffer = new ushort[6];
            outBuffer[0] = (ushort)(READ | XACCL_OUT);
            outBuffer[1] = (ushort)(READ | XGYRO_OUT);
            outBuffer[2] = (ushort)(READ | YGYRO_OUT);
            outBuffer[3] = (ushort)(READ | YACCL_OUT);
            outBuffer[4] = (ushort)(READ | ZACCL_OUT);
            outBuffer[5] = (ushort)(READ | SUPPLY_OUT);
            pSPI.WriteRead(outBuffer, inBuffer);
 
            try
            {
                // output with conversion values
                data[0] = convert14toshort(inBuffer[1]) * 0.07326;    // °/s   xgyro
                data[1] = convert14toshort(inBuffer[2]) * 0.07326;    // °/s  ygyro
                data[2] = convert14toshort(inBuffer[3]) * 2.522;	  // mg xaccl
                data[3] = convert14toshort(inBuffer[4]) * 2.522;	  // mg yaccl
                data[4] = convert14toshort(inBuffer[5]) * 2.522;	  // mg zaccl
            }
            catch (IndexOutOfRangeException)
            {
                Debug.Print("Array too small");
            }
            finally
            {
                outBuffer = null;
                inBuffer = null;
            }
        }