This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DRV8308EVM interface with Hercules 57

Other Parts Discussed in Thread: DRV8308EVM, HALCOGEN, DRV8308, MOTORWARE, DRV8301

Hi,


I've been trying to interface the Hercules with DRV8308 using SPI. I setup the mibspi in halcogen and the scs. I used a charlen of 8 and a transfer group length of 3 which makes it send 24 bits. I played around with the baudrate, but I can't seem to consistently read or write to the drv8308evm. Sometimes I was able to read parts of it. Looking at the waveform output on the oscilloscope, it was sending the correct bits and seemed to be right. I've tried adding delays between each buffer transfer; however, it seemed to make no difference? It would be really helpful if someone has example code or indicate the mistakes I am making. Thank you

  • Edwin,

    You can use a scope to monitor all 4 SPI signals. Do they look normal? Compare the waveform in the DRV8308 datasheet and make sure that data changes at the correct clock edge. I would suggest first trying to read a register which has a non-zero default value. Set SPI clock to about 10 MHz. put a 5K pull up resistor on DRV8308 SPI data put pin because it is open-drain.

    Thanks and regards,

    Zhaohong
  • Hi,
    I checked it with an oscilloscope and it still doesn't seem to work. DX is there code for the MSP430 used on the EVM? Maybe it'll help.
    I tried reading 0x2A which should be none zero; however, I am just getting the pull up values. Here is my code and the driver code is generated with Halcogen. the SCS pin is done using a GIO on NCS2. I have a charlen of 8 and a buffer size of 3 which is 24 bits corresponding to the datasheet.

        rw = 1; addr = 0x2A; data = 0;
        txBuffer[0] = (rw << 7) | (addr & 0x7F);
        txBuffer[1] = (data >> 8) & 0xFF;
        txBuffer[2] = data & 0xFF;
        mibspiSetData(mibspiREG3, 0, txBuffer);
        gioSetBit(mibspiPORT3, 1<<1, 1);
        mibspiTransfer(mibspiREG3, 0);
        while(!(mibspiIsTransferComplete(mibspiREG3,0)));
        gioSetBit(mibspiPORT3,1<<1,0);
        mibspiGetData(mibspiREG3,0,rxBuffer);

    Thanks

  • Edwin,

    Would you please provide more details about "not working"? Did you check the signals on the DRV8308 pins? Did you see the correct waveform? If you see the correct waveform but your data is all "1", it means that DRV8308 is not responding. You need to check other DRV8308 pins to see if it is out of reset.

    You can also check the TI motorware at this link to see if there are any useful information.

    www.ti.com/.../DRV8301-RM48-KIT

    It uses a DRV8301.

    Thanks and regards,

    Zhaohong
  • Hi,
    I've grounded the reset pin and the data read from 0x2A seems to be all 1s which means it is just getting the pull up value. I think it might be a problem with the phase. How can I set the MIBSPI to CPOL 1 and CPHA 1? Right now I am using a GIO for the SCS and all the waveforms seem to match the EVM's MCU output except the delay between the transfer of each 8 bits. I tried achieving the same result using wdelay, but it still did not work. Right now my frequency is set at 10MHz slowing it down and speeding it up did not change anything. I looked at the motorware instaspin code, but found that they used spi instead of mibspi can that be the problem? Thank you
  • Edwin,

    To further debug this issue, you will need to use scope to check the signals on the SPI pins of DRV8308. The MCU needs to send 3 byte for reading a DRV8308 register. First byte is the address and read bit. MCU needs to send two dummy bytes to generated the clocks for reading two bytes back from DRV8308. In the waveform, you should see CS pin is high during the 24 SPI clocks. You should first see the 8 bit data on the data in pin and then 16 bit data on data out pin.

    DRV8308 datasheet indicates that the receive sample happens at the rising edge of SPI clock. You can select Polarity = 0 and Phase = 1 for SPI communication.

    Make sure to check the waveform first!

    Thanks and regards,

    Zhaohong
  • Hi,
    I will look at it under a scope; however, there is a problem after enabling clock phase in mibspi data formats in halcogen. mibspiIsTransferComplete never completes. Is enabling clock phase the correct method to set it in halcogen? Thanks
  • Edwin,

    You should define the clock phase and polarity in Halcogen. There must be something else wrong for the CPU to hang. For this application, you only need to enable three pins as SPI function: clock, mosi (data out) and somi (data in). Leave other pins as GIO (by default).

    Thanks and regards,

    Zhaohong
  • Hi,

    Should the hercules be in master mode?

  • Yes.

    Thanks and regards,

    Zhaohong
  • Hi,
    yay i got it to run; however, it stopped after a second and says RLOCK, what can be the cause of this? It seems to run fine with the same register values in the evm software? Thank you