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.

LAUNCHXL-F28069M: SPI Protocol With Spinning A Motor

Part Number: LAUNCHXL-F28069M
Other Parts Discussed in Thread: MOTORWARE, DRV8305, , DRV8301

Tool/software:

I am currently running proj10d for spinning 2 motors.  I altered the code so SPIB is setup to receive data from a CC2640R2 board.  When I first start the program, the data is coming through perfectly and changes in relation to joystick movement.  However, when I set gSystemVars.Flag_enableRun = true, along with everything else that needs to be true to get the motor spinning, the motor starts to spin, but the data from the (halHandle->spiBHandle->SPIRXBUF) just turns to -1 and stays there.  I tried to comment out code and debug this, but am having no success.  I thought maybe it could be an interrupt priority or something, but I'm not using interrupts for the spib.  Maybe I need to disconnect the interrupt for MTR2?   

Here is the joystick code inside the for(;;) loop of project 10d.  I am trying to manipulate the motor from the joystick position. 

The altered SPIB function



When gSystemVars.Flag_enableRun = 0
you can see below the data is coming through nicely 

Then when I set it to true 

It turns to -1 and stays. 

  • Hello Charlie,

    This one is relatively straightforward. I'm going to assume you're using motorware, the BOOSTXL-DRV8305, and the LAUNCHXL-F28069M. If you are using the DRV8301 instead, simply replace DRV8305 with DRV8301 in all of the below comments. Let's look at a couple functions which are relevant to what you're looking for:

    • HAL_setupSPIB()
      • You've already adjusted this one, which is good
    • HAL_setParamsMtr()
      • Called in proj_lab10d.c immediately after HAL_setupParams
      • Located in the same file as HAL_seutpSPIB()
      • Calls DRV8305_setSpiHandle() which does nothing but store the SPI handle used as an input, which for mtr 2, is the SPI B handle.
    • HAL_readDrvData() and HAL_writeDrvData()
      • These functions are called in the main loop if DRV8305_SPI predefined symbol is enabled. In this case, the SPI Handle which was prev. stored is used in the context of reading from and writing to a DRV8305.

    What is most likely happening is that you have the predefined symbol 'DRV8305_SPI' enabled, and when you enter the main for(;;) loop, you are now writing junk data to SPI comms, and I believe more importantly, clearing the SPI Rx buffer every time the mtr2 section of the loop runs.

    If you're only using one motor, the easiest fix would probably be just to change the for(motorNum...) loop to not iterate to HAL_MTR2.

    Regards,
    Jason Osborn

    Note: Bolding in this post is to indicate key points and takeaways.