Help making ATTiny85 talk to a MCP4151 digipot through software SPI

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

Hi! I've been trying to use a MCP4151 digital potentiometer with an ATTiny85 through software SPI using the ATTinyCore's universal SPI lib. The Tiny does not have hardware SPI like the Mega but the library detects this and uses the right SPI solution automatically (from what I could gather). 

 

I can see my CS pin go down and up but unfortunately I don't have a logic analyzer to help with debugging what's going own in between at my DO pin. My code is basically textbook and the circuit itself is pretty simple so I'm pretty stumped as to why I can't see the resistance between the wipers change.

 

Here's the (very poorly drawn) schematics of what's on my bench

 

Here's my Arduino IDE settings

 

I have tried setting the clock to 1MHz and reburning the bootloader but from my understanding of the MCP4151 datasheet, the maximum clock should be at 1MHz if supply is less than 2.7v and I am using a 5v regulated supply (the same as the AT) which pushes the max clock speed to 10MHz, so I figure 8 MHz is ok - unless I got the whole thing wrong.

 

I am using the digital pot example included with the library except that I pick channel 0 instead of looping through 6 channels. Here it is: https://github.com/SpenceKonde/A...

 

Please let me know if you have any questions and thank you for your time!!

 

EDIT: source and schem in attachment!

 

EDIT 2: Welp, it seems that I might have confused MISO/DO and MOSI/DI. With MISO I thought the *slave* was sending instructions to the *master* and that would correspond to DI but I might have to read a bit more about those. Anyhow, I moved my connection to the pot's SDI to the MISO/DO pin and everything is working fine.

 

Thank you for reading! This seems like a nice forum so I might just hang around! :)

Attachment(s): 

This topic has a solution.
Last Edited: Mon. Jul 9, 2018 - 11:56 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please upload your image files to AVRFreaks, not to a third party for viewing.

 

We'd rather not be involved with whatever tracking mechanisms, advertisements, whatever nastiness which may be present at snag.gy

 

Really don't like their domain name of  snag.gy

 

Stan

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

I understand! Sorry about that! I removed the links and added both schem and IDE conf as post attachments.

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

So everything is working? Maybe you should mark your original post as the solution, then.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The original post doesn't have an original solution button so here it is again:

 

I seem to have mixed up MOSI/DI and MISO/DO pins! I was under the impression that I had to use the MOSI (Master Out, Slave In) pin (PB0) when I had to use the DO (USI Data Out) pin (PB1) - which is also marked as MISO, most probably what confused me.

 

Thank you!