Jump to content

aalsubhi

Members
  • Content Count

    2
  • Joined

  • Last visited

  1. aalsubhi

    MSP430FR5989: SPI interfacing with ISL23428 digipot

    any idea about programming ISL23428 digipot?
  2. 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 PM5CTL0 &= ~LOCKLPM5; // setup UCB1 UCB1CTLW0 = UCSWRST | UCSSEL_2; // UCSWRST= Put USCI in reset mode, UCSSEL_2 = source USCI clock from SMCLK UCB1CTLW0 |= UCCKPH | UCMSB | UCMST | UCSYNC; //UCCKPH = SPI MODE 0(CPOL=0 CPHA=0) , UCMSB= MSB, UCMST= master mode 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 delay(10); digitalPotWrite(); UCB1CTLW0 = UCSWRST; //spi disable for(;;) { } } void digitalPotWrite() { // take the CS pin low to select the chip: P1OUT &= ~BIT0; delay(10); // send writing instruction to WR0 SPI_transfer(0b11000000); // 110 is writing instruction followed by WR0 address(00000) delay(10); SPI_transfer(0b11111111); // set WR0 to max value delay(10); // send writing instruction to WR1 SPI_transfer(0b11000001); // 110 is writing instruction followed by WR1 address(00001) delay(10); SPI_transfer(0b11111111); // set WR1 to max value delay(10); // 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 }
×