UTDesign 0 Posted November 6, 2015 Share Posted November 6, 2015 Hello all, I'm having trouble getting my digital pot to respond to the CC3200. Could someone please take a look at my code and let me know where I'm going wrong? Thanks. DataSheet for the digital pot; http://www.ti.com/product/tpl0501-100 #include <SPI.h> const int SS = 8; uint8_t value; int volts = 0; void setup() { Serial.begin(9600); pinMode(SS, OUTPUT); SPI.begin(); delay(100); } void loop() { for(value = 0; value < 256; value += 20) { digitalWrite(SS, LOW); delay(10); SPI.transfer(value); delay(10); digitalWrite(SS, HIGH); delay(100); } } Quote Link to post Share on other sites
Rei Vilo 695 Posted November 6, 2015 Share Posted November 6, 2015 Four suggestions: Just after pinMode(SS, OUTPUT);set digitalWrite(HIGH); to avoid any interference. Check you're using the correct pins of SPI. Try slower speeds with SPI.setClockDivider(). Check SPI mode and use SPI.setDataMode() accordingly. Quote Link to post Share on other sites
UTDesign 0 Posted November 6, 2015 Author Share Posted November 6, 2015 Something like this? The data sheet says that the digipot is write only: 8bit - MSBFirst - CS~ low to enable write - 24MHZ max clock That would be SPI_MODE1 as I understand it, right? And divide by 4 should reduce the 80MHZ CC3200 clock to a 20MHZ which is below the digipot max. #include <SPI.h> const int SS = 8; uint8_t value; void setup() { pinMode(SS, OUTPUT); digitalWrite(SS, HIGH); SPI.setBitOrder(MSBFIRST); SPI.setDataMode(SPI_MODE1); SPI.setClockDivider(SPI_CLOCK_DIV4); SPI.begin(); delay(100); } void loop() { for(value = 0; value < 256; value += 20) { digitalWrite(SS, LOW); delay(10); SPI.transfer(value); delay(10); digitalWrite(SS, HIGH); delay(100); } } Quote Link to post Share on other sites
Rei Vilo 695 Posted November 6, 2015 Share Posted November 6, 2015 Do you have a logic analyser? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.