user11434: I'm first time working with a Teensy 3.1. I have to connect this (MS5803-01BA: http://www.amsys.de/products/ms5803.htm) pressure sensor via SPI to my Teensy.
My problem is, that I don't have any reliable knowledge on SPI. I read the Wikipedia for it and also the Teensy-Manual.
For the pressure sensor I already got a C-Code but it is only working with the ATMEL ATmega644p microcontroller. I tried to get the code to work with my Teensy, but it seems like I don't get either any input nor any output.
I hope that one of you can help me with the following code and tell me what I'm missing out on. Thank you.
Code:
http://pastebin.com/xaWXfRUR
Datasheet of the pressure sensor:
http://www.amsys.de/sheets/amsys.de.ms5803_01b.pdf
C-Code for the pressure sensor for the ATMEL ATmega644p microcontroller:
http://www.amsys.de/sheets/amsys.de.an520_e.pdf

PS: Please excuse my not perfect English for it's not my native language.

user10794: Details about SPI at SPI - Serial Peripheral Interface - for Arduino
This isn't right:
  SPI.transfer(CMD_ADC_READ); // send ADC read command
  SPDR = SPI.transfer(0x00); // send 0 to read 1st byte (MSB)
  ret = SPDR;
  temp = 65536 * ret;
  SPDR = SPI.transfer(0x00); // send 0 to read 2nd byte
  ret = SPDR;
  temp = temp + 256 * ret;
  SPDR = SPI.transfer(0x00); // send 0 to read 3rd byte (LSB)

The SPI library handles SPDR for you. Writing to it yourself will corrupt its behaviour.
It should be more like:
  SPI.transfer(CMD_ADC_READ); // send ADC read command
  ret = SPI.transfer(0x00); // send 0 to read 1st byte (MSB)
  temp = 65536 * ret;
  ret = SPI.transfer(0x00); // send 0 to read 2nd byte
  temp = temp + 256 * ret;
  ret = SPI.transfer(0x00); // send 0 to read 3rd byte (LSB)

Ditto for elsewhere.

11434: <p>I'm first time working with a Teensy 3.1. I have to connect this (MS5803-01BA: <a href="http://www.amsys.de/products/ms5803.htm" rel="nofollow">http://www.amsys.de/products/ms5803.htm</a>) pressure sensor via SPI to my Teensy.</p>

<p>My problem is, that I don't have any reliable knowledge on SPI. I read the Wikipedia for it and also the Teensy-Manual.</p>

<p>For the pressure sensor I already got a C-Code but it is only working with the ATMEL ATmega644p microcontroller. I tried to get the code to work with my Teensy, but it seems like I don't get either any input nor any output.</p>

<p>I hope that one of you can help me with the following code and tell me what I'm missing out on. Thank you.</p>

<p>Code:</p>

<p><a href="http://pastebin.com/xaWXfRUR" rel="nofollow">http://pastebin.com/xaWXfRUR</a></p>

<p>Datasheet of the pressure sensor:</p>

<p><a href="http://www.amsys.de/sheets/amsys.de.ms5803_01b.pdf" rel="nofollow">http://www.amsys.de/sheets/amsys.de.ms5803_01b.pdf</a></p>

<p>C-Code for the pressure sensor for the ATMEL ATmega644p microcontroller:
<a href="http://www.amsys.de/sheets/amsys.de.an520_e.pdf" rel="nofollow">http://www.amsys.de/sheets/amsys.de.an520_e.pdf</a></p>

<hr>

<p>PS: Please excuse my not perfect English for it's not my native language.</p>
 10794: <p>Details about SPI at <a href="http://www.gammon.com.au/spi" rel="nofollow">SPI - Serial Peripheral Interface - for Arduino</a></p>

<p>This isn't right:</p>

<pre><code>  SPI.transfer(CMD_ADC_READ); // send ADC read command
  SPDR = SPI.transfer(0x00); // send 0 to read 1st byte (MSB)
  ret = SPDR;
  temp = 65536 * ret;
  SPDR = SPI.transfer(0x00); // send 0 to read 2nd byte
  ret = SPDR;
  temp = temp + 256 * ret;
  SPDR = SPI.transfer(0x00); // send 0 to read 3rd byte (LSB)
</code></pre>

<p>The SPI library handles SPDR for you. Writing to it yourself will corrupt its behaviour.</p>

<p>It should be more like:</p>

<pre><code>  SPI.transfer(CMD_ADC_READ); // send ADC read command
  ret = SPI.transfer(0x00); // send 0 to read 1st byte (MSB)
  temp = 65536 * ret;
  ret = SPI.transfer(0x00); // send 0 to read 2nd byte
  temp = temp + 256 * ret;
  ret = SPI.transfer(0x00); // send 0 to read 3rd byte (LSB)
</code></pre>

<p>Ditto for elsewhere.</p>
