Jump to content

MSP430FR5989: SPI interfacing with ISL23428 digipot

Recommended Posts

Hello there,

I'm trying to program the digipot using spi communication to set the ISL23428 digipots to thier maximum values. I used the multimeter to inspect the output voltage for each digipots and the result is zero for both. I'm not sure if the issue is in my code or with the digipots.  Thanks in advance for your help.


#include <msp430fr5989.h>
#include <stdint.h>

#define delay(x) __delay_cycles(x * 8000UL)

void digitalPotWrite();
uint8_t SPI_transfer(uint8_t _data);
uint8_t spi_send(const uint8_t _data);

void main(void)
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer

// setup UCB1
 UCB1CTLW0 = UCSWRST | UCSSEL_2; // UCSWRST= Put USCI in reset mode, UCSSEL_2 = source USCI clock from SMCLK

 P3SEL0 |= BIT1;  // P3.1-> UCB1SIMO
 P3SEL1 &= ~ BIT1;
 P3SEL0 |= BIT2 ; //P3.2-> UCB1SOMI
 P3SEL1 &= ~ BIT2 ;
 P3SEL0 |= BIT0 ; //P3.0-> USCB1CLK
 P3SEL1 &= ~ BIT0 ;
 P1OUT |= BIT0;
 P1DIR |= BIT0; // set cs P1.0 as output
 // UCB1 set initial speed
 UCB1BR0 |= 0x02;
 UCB1BR1 = 0;
 UCB1CTLW0 &= ~UCSWRST; // release UCB1 for operation

 UCB1CTLW0 = UCSWRST; //spi disable


 void digitalPotWrite() {
   // take the CS pin low to select the chip:
   P1OUT &= ~BIT0;
   // send writing instruction to WR0
   SPI_transfer(0b11000000); // 110 is writing instruction followed by WR0 address(00000)
   SPI_transfer(0b11111111); // set WR0 to max value
   // send writing instruction to WR1
   SPI_transfer(0b11000001); // 110 is writing instruction followed by WR1 address(00001)
   SPI_transfer(0b11111111); // set WR1 to max value
   // take the CS pin high to de-select the chip:
   P1OUT |= BIT0;

 uint8_t SPI_transfer(uint8_t _data) {
     return spi_send(_data);

 uint8_t spi_send(const uint8_t _data)
 	/* Wait for previous tx to complete. */
 	while (!(UCB1IFG & UCTXIFG)) // UCB1 flage

 	/* Setting TXBUF clears the TXIFG flag. */
 	UCB1TXBUF = _data; // transfer buffer for UCB1

 	/* Wait for a rx character? */
 	while (!(UCB1IFG & UCRXIFG)) // UCB1 flage

 	/* Reading clears RXIFG flag. */
 	return UCB1RXBUF; //reciveing buffer for UCB1
Link to post
Share on other sites
  • 2 weeks later...

cannot help you with your code. but happy to offer you an approach.

as written, your code has poor reusability -> meaning you or others will have a hard time re-use the code in another project, with all those hard coded pins / ports.

1) read the datasheet thoroughly and understand what's needed to communicate with the device for your application and how the communications work. for example, do you need all CS/SCK/SDI/SDO or just CS/SCK/SDI? ... Form logic pins for those connections.


2) write a basic set of routines that communicate with the device. the datasheet says that it is always one command / instruction byte + data bytes. if you don't mind a little bit of inefficiency, a isl23428_write(cmd, data) + is23428_read(cmd, addr) would work, using logic pins in 1) above


3) with that, you can then write another set of routines writing specific data to dcp channels, or the control register, using routines developed in 2).


4) from there, you can develop your applications.


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...