Quantcast
Channel: Motor drivers forum - Recent Threads
Viewing all articles
Browse latest Browse all 21633

RE: DRV8301: DRV 8301 SPI write not working

$
0
0

#include <SPI.h> #define ss digitalWrite(10, LOW); #define nss digitalWrite(10, HIGH); const int chipSelectPin = 10; const int EN_GATE = 8; void setup() { Serial.begin(9600); pinMode(chipSelectPin, OUTPUT); pinMode(EN_GATE, OUTPUT); digitalWrite(EN_GATE, HIGH); digitalWrite(chipSelectPin, LOW); SPI.begin(); // DRV8301 communicates with MSB first and has low clock polarity and data is shifted on rising edge // SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE1)); SPI.setBitOrder(MSBFIRST); SPI.setDataMode(SPI_MODE1); // While Idle SPI CLK = 0, falling Egde latching for Rx } void loop() { readRegister(0x02); delay(5000); } unsigned int readRegister(byte Register ) { uint16_t dataToSend = 0x0000,dataToRead = 0; // bit 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 // R=1/W=0 |-Raddr--| |-----------Data---------------------| // Fault=1/0 |-Raddr--| |-----------Data---------------------| dataToSend |= ( 0x0010 | Register) ; dataToSend <<= 11; Serial.print("Sending read command: "); Serial.println(dataToSend,HEX); ss Serial.println(SPI.transfer16(dataToSend),HEX); Serial.println(SPI.transfer16(dataToSend),HEX); nss } void writeRegister(byte Register, byte Value) { uint16_t dataToSend = 0; // bit 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 // R=1/W=0 |-Raddr--| |-----------Data---------------------| dataToSend |= Register ; dataToSend <<= 11; dataToSend |= Value; Serial.print("Sending write command: "); Serial.println(dataToSend,HEX); ss Serial.println(SPI.transfer16(dataToSend),HEX); //Send value to record into register nss // take the chip select high to de-select: Serial.print("Reading reply for write command: "); Serial.println(dataToSend,HEX); }

Hi Rick,

       Above is arduino code I'm using to print SPI data received twice. Attached is figure from DSO I observed that there is no signal on MISO pin even after trying for more than half and hour. I measured supply current to DRV8301 it takes about 50mA at 24V when only SPI is powered on. And DRV heats up to 130 C temperature in just 15 minutes. I have not connected any MOSFET circuitry to DRV but rest of the circuitry is same as shown in reference design and it still is heating up a lot.

In figure, topmost signal is clock, then second is MOSI(from microcontroller) then third is MISO and fourth is slaveSelect.

What am I missing?


Viewing all articles
Browse latest Browse all 21633

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>