SPI library on T4.0

greg

Well-known member
Hi,

Trying to get an MCP4151 digital pot ((https://ww1.microchip.com/downloads/en/DeviceDoc/22060b.pdf) working with T4 to control a resistor on an adjustable voltage reg, thus making it programmatically settable.

6 hours of poking around, and still no joy. Before I post any code/diagrams, that does not do what its supposed to, want to make sure I use the right library.

I have one SPI.h/.cpp that came with Teensyduino (version=1.8.5). Windiff shows substantial difference with this: https://github.com/PaulStoffregen/SPI?tab=readme-ov-file

Which one is the right one?

Thanks!
 
1.8.5 sounds like a version of Arduino IDE, not of TeensyDuino. The latest TeensyDuino is 1.59, just released last week. Arduino 1.8.5 goes back quite a ways, so it might be a good idea to update to the latest (Arduino 1.8.19 and TeensyDuino 1.59).
 
want to make sure I use the right library.

Yes, confirm SPI.h.

To check further, first click File > Preference in Arduino IDE. Turn on verbose output during compile.

Arduino IDE will print a lot of info. Near the end (you may need to scroll up to see it) will be a list of the libraries it used, with the full pathnames. This is important, because you probably have several SPI.h, each meant for different types of boards. If the SPI.h you are viewing is substantially different than the copy on my GitHub account, very likely you're reading the wrong copy. Use the full pathname to be certain you are viewing the files for the copy Arduino IDE actually uses with Teensy.
 
Thanks, guys. Sorry, to clarify, I am on Arduino 1.8.19

This is what I see in the verbose compile output:
Using library SPI at version 1.0 in folder: C:\Dev\arduino-1.8.19\hardware\teensy\avr\libraries\SPI

Just wanted to make sure the above GitHub is the correct version. I'll download the SPI.cpp/h from the github and overwrite the one I have there, and make sure there are no other SPI.cpp/h anywhere where compiler might find them (although it typically warns, if there are multiple copies)
 
I'll download the SPI.cpp/h from the github and overwrite the one I have there

Not a good plan. SPI.h is among the many libraries from the Teensyduino installer. They are tested together and meant to be used together. If you upgrade or change one library without the others, it might work, but you might also run into all sorts of strange and difficult to diagnose issues.

Use the installer to get this library together with all the others.


(scroll down to "Arduino 1.8.x Software Development" for the installers that work with Arduino 1.8.19)
 
Thanks all! Upgraded to latest Arduino and Teensyduino. It all works as expected.

Unrelated to Teensy, I did realize I can not use MCP4151 or any other DigiPot I could find to replace an analog pot on a 3v-12v adjustable power voltage reg, since MCP4151 has as a max voltage limited by 3.3v. Higher voltage models, on the other hand, like MCP41HVx have a lower limit of 10v.
 
Back
Top