SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By BigPilot
#115255
I'm unable to get my SCP1000 breakout board to work with my Arduino-like FEZDomino (.NET Micro Framework). I'm looking for ideas what about what could be the problem. The board itself supplies 3.3.V so there's no power supply problem. I can't get a good measurement with my portable scope so I'm not sure if the MISO and MOSI and SCK show waveforms but my multimeter does see activity on the CSB pin (it momentarily drops from 3.3V to 2.5V, but it might be because of averaging.
By DaveAK
#115269
I have one of these hooked up to an Arduino Pro Mini. I also have one that I think I may have blown up, so be advised that they may be a little touchy to voltages and ESD. Are the I/O pins also 3.3V on the FEZ? Why can't you get a measurement with your scope? Have you had any other SPI devices working with the FEZ?

Sorry if some of this seems obvious, but I don't know where you're at with any of it, and I'm by no means an expert.

I got most of my advice over at the Arduino forums. Here's a thread with some example Arduino code so you can see if perhaps you're missing a step somewhere.

http://www.arduino.cc/cgi-bin/yabb2/YaB ... 3720/14#14
By BigPilot
#115272
I looked at the Arduino C code and it looks similar to what I have. I'm using a SPI.Configuration object. See http://msdn.microsoft.com/en-us/library/cc544112.aspx. It also specifies a setup and hold time and I've set those to 0 and I'm unsure if that affects the transfers but I don't see any reference to it in the C code.
Code: Select all
static SPI.Configuration m_SPIConfig4PressureSensor = new SPI.Configuration((Cpu.Pin)FEZ_Pin.Digital.Di10, false, 0, 0, false, true, 125, SPI.SPI_module.SPI1);
and in the Init() I check for the Revision ID:
Code: Select all
        private static void InitPressureSensor()
        {
            Thread.Sleep(200);

            byte[] arrTxData = new byte[1];
            arrTxData[0] = 0x00;
            byte[] arrRxData = new byte[1];

            m_PressureSensor.WriteRead(arrTxData, arrRxData);

            WriteLineToFile("SCP1000 ASIC version: " + arrRxData[0].ToString());

            if (arrRxData[0] != 0x03)      // if we didn't get the expected version number
            {
                throw new InvalidOperationException("The pressure sensor could not be initialized");
            }
        }
I previously owned another SCP1000 breakout board which I purchased in 2007. After many fruitless tries and asking around people remarked that it was probably defective, although I did see waveforms on the MOSI but not the MISO. I threw it out and bought a new one, but to my horror I can't get this one to work either. For some reason I don't see any waveforms on my scope this time, but I just ordered a new scope (Sparkfun Open-source scope).

But maybe I'm missing something obvious. I haven't found anyone who's got SCP1000 working with .NET Micro Framework so I can't compare source code.
By BigPilot
#115296
I got it working! The problem stemmed from my assumption about how the WriteRead() method works. If I want to read one byte from a register I assumed that the read and write buffers needed to be only one byte big and that the WriteRead() implementation would add these two together and handle the merry-go-round transfer. Wrong! You need two bytes for both the input and the output buffer and the result is in the second byte of the output buffer.

Here's my reworked code:

I changed the configuration slightly but that probably makes not much difference. The transfer speed is tricky, though. It needs to be at least 400khz or the WriteRead() will throw an exception.
Code: Select all
static SPI.Configuration m_SPIConfig4PressureSensor = new SPI.Configuration((Cpu.Pin)FEZ_Pin.Digital.Di10, false, 100, 20, false, true, 500, SPI.SPI_module.SPI1);
The reworked Initialize method:
Code: Select all
        private static void InitPressureSensor()
        {
            Thread.Sleep(200);

            byte[] arrTxData = new byte[] { 0x00, 0xff };
            byte[] arrRxData = new byte[] { 0xff, 0xff };

            m_PressureSensor.WriteRead(arrTxData, arrRxData);

            WriteLineToFile("SCP1000 ASIC version: " + arrRxData[0].ToString());

            if (arrRxData[1] != 0x03)      // if we didn't get the expected version number
            {
                throw new InvalidOperationException("The pressure sensor could not be initialized");
            }
        }