SPI communication with DRV8711 BoosterPack Board

Hi all,

I have recently bought TI’s DRV8711 BoosterPack Board http://www.ti.com/tool/boost-drv8711.

I am new to Arduino SPI coding. So I am using the default SPI library.

Here is my code just to read the torque register.

#include <SPI.h>
#  define CSpin    4
#  define STEPpin  5
#  define DIRpin   6
#  define RESETpin 7
void setup() {
  // put your setup code here, to run once:
  pinMode(CSpin,OUTPUT);
  SPI.beginTransaction(SPISettings(1000000, LSBFIRST, SPI_MODE0));
  SPI.begin();
  Serial.begin(9600);
  Serial.print("SPCR: ");
  Serial.println(SPCR,BIN);
  digitalWrite(CSpin,HIGH);
  SPI.transfer(0x9);//selecting torque register to read
  int data=SPI.transfer(0x00);
  Serial.print("Torque register: ");
  Serial.println(0x9,BIN);
  Serial.print("Torque register return value: ");
  Serial.println(data,BIN);
}

void loop() {
  // put your main code here, to run repeatedly:

}

I feel the TORQUE register is returning wrong value.
Also When I checked the SPCR register, the MSTR bit is LOW.
I am not able to figure it out why my Arduino is not in Master mode?

KIndly guide me. I have been trying to understand since two days.

arduino.png

Board?

Arduino Uno. :)

I am not able to figure it out why my Arduino is not in Master mode?

Pin 10 is the hardware Slave Select not pin 4. You can use pin 4 for your particle device but pin 10 has to be an output. The documentation has more details...

http://www.arduino.cc/en/reference/SPI

  digitalWrite(CSpin,HIGH);
  SPI.transfer(0x9);//selecting torque register to read

Is HIGH slave select for your device?

Yes High is for Slave select. I have corrected the CSpin to PIN 10, But still On reading the SPCR register, I am not able to see the MSTR bit high.

#include <SPI.h>
#  define CSpin    10
#  define STEPpin  5
#  define DIRpin   6
#  define RESETpin 7
void setup() {
  // put your setup code here, to run once:
  pinMode(CSpin,OUTPUT);
  SPI.beginTransaction(SPISettings(1000000, LSBFIRST, SPI_MODE0));
  SPI.begin();
  Serial.begin(9600);
  Serial.print("SPCR: ");
  Serial.println(SPCR,BIN);
  digitalWrite(CSpin,HIGH);
  SPI.transfer(0x9);//selecting torque register to read
  int data=SPI.transfer(0x00);
  Serial.print("Torque register: ");
  Serial.println(0x9,BIN);
  Serial.print("Torque register return value: ");
  Serial.println(data,BIN);
}

void loop() {
  // put your main code here, to run repeatedly:

}

I have been trying the other way by using the DRV8711 library took from here.

I have used the flow of programming into mine.
But now the problem is : I am getting the register value as 1111111111111111.

Whereas by using the library above, the code returns perfect values.

Where did I mess??

Here are the files of my learning project.

DRIVER_8711.ino (499 Bytes)

drv8711.h (3.36 KB)

DRVextn.ino (2.03 KB)