MCP4251 and Teensy 4.1

toyosm

Active member
Hello everyone I'm having some issues with the digital pot MCP4251 and Teensy 4.1, cannot make it work, the resistor values are fixed and not responding. Here are my connections:

  1. Chip Select: Teensy Pin 4
  2. SCK: Teensy Pin 13 (SCK)
  3. MOSI: Teensy Pin 11 (MOSI)
  4. VSS: GND
  5. POT0 pin 1
  6. POT0 wiper
  7. POT0 pin 2
  8. POT1 pin 2
  9. POT1 wiper
  10. POT1 pin 1
  11. WP: 3v3
  12. SHDN: 3v3
  13. SDO: unconnected
  14. VDD: 3v3
And here's the code I'm trying:

Code:
#include <SPI.h>
#define POT0    0
#define POT1    1
#define DIGIPOT_CS  4

void setup() {
  // put your setup code here, to run once:
  pinMode(DIGIPOT_CS, OUTPUT);
  SPI.begin();
}
void loop()
{
    for(int i =0; i < 255; i++)
    {
          digiPot(DIGIPOT_CS, POT0, i);
          digiPot(DIGIPOT_CS, POT1, i);
    }
}

void digiPot (byte chip_select, byte address, byte value)
{
  digitalWrite(chip_select, LOW);
  SPI.transfer(address << 4);
  SPI.transfer(value & 255);
  digitalWrite(chip_select, HIGH);
}

All connections are as shown (on a custom PCB and on a breadboard) but I don't have any change in the resistance between wiper and Pin 1 or 2 for either pots. Any suggestions?
 
I tried the SPI.beginTransaction with no success. The only think that worked was to power the MCP with 5V (control lines in 3v3). It's weird because the datasheet states an min operating voltage of 2.7V and found a post around (not here) of a guy using it with a Teensy 3.6 on 3v3.
 
Back
Top