FEZ Panda II and SPI

I am trying to follow and expand on the SPI tutorial.

First, I am trying to figure out what the GPIO pins map to. When I type in Cpu.Pin. , it gives me the option of NO chip select pin up to GPIO_Pin15. I have put in GPIO_Pin1, but do not have a scope to figure out which pin that is.

Also, I have implemented a ADT7311 temperature sensor and am confused as to reading data back.

In the tutorial, the following is used:

      byte[] tx_data = new byte[10];
      byte[] rx_data = new byte[10];

      MySPI.WriteRead(tx_data, rx_data);

How would I look at the rx_data?


Use FEZ_Pin cast to a Cpu.Pin, such as:

The pinout can be found in the FEZ Panda II User Manual:
SPI is Di11 (output), Di12 (input), and Di13 (clock)

What exactly do you mean by "look at"?  Do you need an integer or float value or what?
1 Like

I want to be able to read back the chip ID. I assume that instantiation of a receive array object will be written to during a WRITEREAD command. How do I look at the receive array to see if the correct chip ID has been read?



@ Slappedhard - To read data like that, you would need to know how the SPI comands work on your sensor. The datasheet should tell you how to read that kind of information. you would send the commands in the write buffer then what it is supposed to return would be in the read buffer. It would be in hex however.

1 Like

It looks like page 15 has the relevant information (I already had the datasheet open out of curiosity). When you read register 0x03, you should get back a byte, or eight bits. The first (LSB) 3 bits represent the silicon revision and the remaining 5 represent the manufacturer ID. This will probably be in the last byte of your read buffer. From your profile, I assume you can shift bits, etc. to get the values from that.

1 Like

I understand the functionality of SPI (synthesizer designer at work), it is the programming side that confuses me.

Since the SPI functions accept and array, I assume that I can send it multiple 8-bit words in one command.

One of the first things that the ADT7311 tells you to do is the reset the serial inter face by sending 32 consecutive 1s. I am bit banging it now, so no fancy programming at this point.

What I did was define and new instance of writeBuffer and then filled it with 1s

byte[] writeBuffer = new byte[4];
writeBuffer[0] = 0xff;
writeBuffer[1] = 0xff;
writeBuffer[2] = 0xff;
writeBuffer[3] = 0xff;


I assume that the SPI class will take the chip select low, send all four 8-bit words and then bring the chip select high.

Is this true?