Difficulty reading registers of DRV8308EVM using SPI with Teensy 3.6 as a master

Status
Not open for further replies.

a_mandana

New member
Hi,

We have been working on trying to bypass the onboard MCU of Texas Instruments' DRV8308EVM so that we can use a Teensy 3.6 (master) to communicate with the DRV8308EVM (slave) to control a motor (using SPI communication). The SPI communication using Teensy 3.6 is where we have been facing issues - the only output that we are able to read from the SDATO pin of the DRV8308EVM (MISO) is all 1's. Using an oscilloscope, we are able to verify that SCLK and MOSI signals from the Teensy 3.6 are correct. We have tried reading the fault register (0x2A) of the DRV8308EVM which is supposed to return a non-zero value of 0x18, and we have tried writing and reading to other registers as well, but the output is always 1's. Our SPI settings are: 1Mhz, SPI_MODE0. We have followed the SPI timing requirements mentioned in the TI manual to make sure there is the right time between SPI CLK rising edges and MOSI rising edges, and we have ensured that SCS is high for serial interface communication (this is required for the DRV8308EVM according to the manual).

The same thing works when we use an Arduino Uno board with the DRV8308EVM. We were able to write and read data to the DRV8308EVM successfully. We have been going through issues on the TI forums as well and have included a 5K pull-up resistor on the MISO pin to connect it to 3.3V on the Teensy 3.6.

The code that we have been using is:

Code:
#include <SPI.h>

SPISettings settings(1000000, MSBFIRST, SPI_MODE0);
const int slavePIN = 10;

void setup() {
Serial.begin(9600);
pinMode(slavePIN, OUTPUT);
digitalWrite(slavePIN, LOW);

SPI.begin();
}

void loop() {
SPI.beginTransaction(settings);
digitalWrite(slavePIN, HIGH); //driving it high to start serial interface of DRV8308EVM
SPI.transfer(B00000000);   //first 0 for the write command and remaining 0s for the address of 0x00 register
SPI.transfer(B00000000); //writing the first byte
SPI.transfer(B10000000); //writing the second byte
digitalWrite(slavePIN, LOW);
delay(1);

digitalWrite(slavePIN, HIGH);
SPI.transfer(B10000000); //first 1 for read command and remaining 0s for the address of 0x00 register
unsigned int A0x00p = SPI.transfer16(0); //ignored data since read command was sent before this
Serial.println(A0x00p,BIN);
digitalErite(slavePIN, LOW);

SPI.endTransaction();
delay(100);
}

To make sure that this is not an issue with our Teensy 3.6 board, we tried out code from this forum post with one T3.6 as master and one T3.6 as a slave: https://forum.pjrc.com/threads/55103-SPI-Slave , from tonton81's MST.zip folder (post#14 in the thread) and the SPI communication worked.

We have tried this with many SPI clock frequencies (ranging from 500kHz to 16Mhz). Is there something that we have not understood correctly regarding how to program the Teensy 3.6 for SPI communication? Any help would be much appreciated. Thanks!
 
Maye the 180mhz T3.6 is too fast, you might try adding a small delay before each digitalWrite(slavePIN, LOW);
and maybe after digitalWrite(slavePIN, HIGH);

Sanity check: "most" SPI devices use CS pin LOW to start transfer, and CS pin HIGH to end (and setup() starst CS HIGH). Do the specs for your device require this protocol or the inverted protocol of your sketch??

is the device running from 5v? T3.6 pins are not 5v tolerant.
 
Status
Not open for further replies.
Back
Top