atMega2560 and DRV8889

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi All,

I am using (well trying to use) a TI DRV8889 stepper motor with the atMega2560.

It supports a logic interface with separate pins for step, direction etc. It also has an SPI interface. This latter is causing me grief.

 

I have tested the SPI interface in loop-back mode and this works fine (SS problem encountered, learned, fixed).

However.... I am not having a lot of joy getting the SPI to talk to the DRV8889.

 

I have viewed some TI example code in C (for another uC). Notwithstanding that this example code uses a different message format to the data sheet, I seem to be doing the right things.... but rx only zeros (i.e. nothing).

 

I was wondering if anyone here has some experience with this TI stepper driver?

 

Thanks

Greg

regards
Greg

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have you asked TI ?

 

https://www.ti.com/product/DRV8889-Q1#support-training

 

Have you used a scope or logic analyser to see what's actually happening on the wires ?

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

However.... I am not having a lot of joy getting the SPI to talk to the DRV8889.

Even though you don't get any data from it, can you actually take steps?  That would say you are successfully writing TO it.  Maybe you are having issues with getting a response (maybe it really is sending back zeros).  Saying motors are taking steps, shows it is at least getting what you send to it.

 

This might sound foolish, but you are keeping pin nSCS low (activate Serial Chip Select) low, correct?...   Also SDO has its own power pin (strange)  VSDO....so no power, no reply.  

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Tue. May 5, 2020 - 05:45 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Guys,

I got back to this and as usual it was a silly config error. I had set the relevant three SPI pins as outputs... except I had set one as an output twice and missed one.

 

Unsurprisingly, it now works!

 

Thanks for your suggestions.

 

Regards

Greg

regards
Greg

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gregd99 wrote:
it now works!

Thanks for feedback

 

Now please mark the solution - see Tip #5 in my signature, below:

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 except I had set one as an output twice and missed one

How do you set one twice?

 

Don't you in the beginning of your program, say: 

DDRA = xxxxxx; //config port A pin directions  

DDRB = yyyyyy; //config port B pin directions 

DDRC = zzzzzzz; //config port C pin directions

 

 

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Tue. May 19, 2020 - 04:30 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:
How do you set one twice?

maybe he has some sort of set_pin_as_output() function or macro - and "accidentally" set the same pin twice, instead of 2 different pins ?

(cop & paste error)

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...