SPI Chip Select after 32 bits

@ Errol, Oops sorry I only just realized that I misspelt Errol as Error… U sure you don’t want to change that name? :-[ Just kidding.

Ok on page 25 of the LPC2388 datasheet it states that the SPI can only send data in 8 or 16 bits at a time. This means that to do more than that it will have to use RLP (as Gus rightly suggested). Beyond that it will have to be done in hardware.

It still gonna be in transactions of 8 or 16, no matter what.

I don’t have any problems talking to these chips by sending a byte at a time so I’m not sure what the perceived need for the CS after 32 bits is from.

The need for word lengths greater than 16 results from the fact that the device can be daisy chained. each device uses 8 bits and if there are 8 devices in the chain then the word length would have to be 64 bits.

AFAIK, when you write out a buffer of bytes the CS will remain low until you have written out the whole buffer. I have not actually measured this, but if it were not this way you would never be able to talk to even one of these driver chips. A single command transaction is up to four bytes with up to a three byte response. A command such as ‘Run’ takes three bytes, the command itself and two argument bytes. The driver chip has to have all of this information at once in order to process the command so it makes no sense that the CS would toggle after each byte.

I could be wrong but it seems to work for me.

Nah, CS toggles after every 8 bits.

Can you prove that CS toggles after every byte? What is your evidence? What does your code look like?

I have worked with a CC1101 chip connected over SPI to an EMX module. The CC1101 requires the CS to be low through the whole transaction, which can be up to 34 bytes.

This did work.

I also connected a Logic Analyser to the bus to verify comms. CS did NOT toggle between every byte…

Thus, if it doesn’t work then it is something in your code…

@ Errol, (lol almost typed error again) I can’t prove that it toggles, as I don’t have a logic analyzer (but I’ll definitely get one). I’ve going on information that I got from the forums. Perhaps it’s a code thing. Can you post that test code?

using System;
using System.Threading;

using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

using GHIElectronics.NETMF.FEZ;

namespace FEZ_Panda_Application1
{
    public class Program
    {
        public static void Main()
        {
            // Blink board LED

            bool ledState = false;

            OutputPort led = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, ledState);
            SPI spiPort=new SPI(new SPI.Configuration((Cpu.Pin)FEZ_Pin.Digital.UEXT10,false,10,10,true,false,1000, SPI.SPI_module.SPI2));
            byte[] Data=new byte[]{1,2,3,4,5,6,7,8,9};
            while (true)
            {
                spiPort.Write(Data);
                // Sleep for 500 milliseconds
                Thread.Sleep(500);

                // toggle LED state
                ledState = !ledState;
                led.Write(ledState);
            }
        }

    }
}

Perhaps it’s your configuration; I will look into it more. It was trouble just getting the stepper driver to talk to the fez in the first place perhaps there are options on the SPI that I don’t fully understand.

Also what is the logic analyzer hardware that you are using?

@ Errol, It seems the difference between your code and mine is subtle. true, Clock_Edge is true in my code and false in yours.

/* Initialize peripherals used by dSPIN */
            SPI.Configuration _spiConfig = new SPI.Configuration((Cpu.Pin)FEZ_Pin.Digital.Di10,
                !true, // Chip Select, active-low
                1000, // 1000 (nanoseconds?) setup time
                1000, // 1000 (nanoseconds?) hold time
                true, // Clock low on idle    
                true, // Data valid on falling edge
                5000, // 5Mhz Clock Rate
                SPI.SPI_module.SPI1); //SPI device 1

Switch your clock edge to true and see if you get CS toggle after each byte.

(I have got to get a logic analyzer)

That setting just sets weither the data is valid on the rising or falling edge.

Did a trace anyway.

I’m using OLS for this(http://www.seeedstudio.com/depot/open-workbench-logic-sniffer-p-612.html?cPath=174). It isn’t a bad tool for $50, with the latest rom files and the latest client, which mine didn’t ship with and I had to reflash.

At work I use a Logic16, which is a really nice LA, but it doesn’t really have the speed of OLS, but it’s client is REALLY nice. But it is $300 so…

Back to your SPI issue. Remember that you must ALWAYS send 4 bytes per transaction, the first byte will be for the last chip, second byte for the second last chip etc. If you don’t have a command for a chip, or it’s command was shorter than the other commands, then you need to send a NOP byte for that chip’s byte.

BTW

1000, // 1000 (nanoseconds?) setup time

That measurement is in microseconds