AnsweredAssumed Answered

interfacing AD9951 with MSP430

Question asked by debasish on Apr 11, 2013
Latest reply on Apr 14, 2013 by LouijieC

Hi,

I am trying to run two AD9951 with MSP430F5436A through SPI. But I am not able to read back from the DDS.

I have tried the following code but it doesnot work.

#################################################################################

void portinit(void)

{ P9DIR |= 0xFF;                   //setting port 9 to output port

  P9SEL |= 0x0E;                  //selecting 9.1,9.2,9.3 for SPI

  P9OUT |= BIT0;                  // assert RESET

  __delay_cycles(100);

  P9OUT &= ~BIT0;                 // release RESET

  P9OUT |= BIT4;                  // CSO enable not set

  P9OUT |= BIT5;                  // CS1 enable not set

  P9OUT &= ~BIT6;                 // PWRDWNCTL0 kept low

  P9OUT &= ~BIT7;                 // PWRDWNCTL1 kept low

//................... setting up of port 8 pins.................................

P8DIR |= 0xFF;                      //setting port 8 to output port

  P8OUT &= ~BIT0;                  // IO_UPDATE kept low            

  P8OUT &= ~BIT1;                  // IOSYNC kept low

  P8OUT &= ~BIT2;                  //  OSK0  kept low

  P8OUT &= ~BIT3;                  //  OSK1   kept low

  P8OUT |= BIT4;                     //   CLKMDESLCT kept high

  P8OUT |= BIT5;                     //   CLKMDESLCT kept high                

//....................setting up SPI............................................ 

 

  UCB2CTL0 |= UCMSB+UCMST+UCCKPL+UCSYNC+UCMODE0;   //3wire SPI

  UCB2CTL1 |= UCSSEL1+UCSWRST;                     // SMCLK selected

  UCB2BR1 = 00;                   //divisor clock selected clock

  UCB2BR0 = 01;                   // division by 1

  UCB2CTL1 &= ~UCSWRST;          

}

uint8_t setCFR1_AD9951_1(void)

{

  uint8_t x;

  P9OUT &= ~BIT4;                                   //CS0 set

  P9OUT |= BIT5;                                       //CS0 disabled    

while (!(UCB2IFG&UCTXIFG));              

  UCB2TXBUF = 0x02;

  while (!(UCB2IFG&UCRXIFG));               

  x = UCB2RXBUF;

  while (!(UCB2IFG&UCTXIFG));              

  UCB2TXBUF = 0x11;

  while (!(UCB2IFG&UCRXIFG));               

  x = UCB2RXBUF;

  while (!(UCB2IFG&UCTXIFG));              

  UCB2TXBUF = 0x12;

   while (!(UCB2IFG&UCRXIFG));               

  x = UCB2RXBUF;

  while (!(UCB2IFG&UCTXIFG));

   // for reading from the same register      

  UCB2TXBUF = 0x82;

  while (!(UCB2IFG&UCRXIFG));               

  x = UCB2RXBUF;

  while (!(UCB2IFG&UCTXIFG));              

  UCB2TXBUF = 0x00;

  while (!(UCB2IFG&UCRXIFG));                //dummy byte TX

  x = UCB2RXBUF;

  while (!(UCB2IFG&UCTXIFG));              

  UCB2TXBUF = 0x00;

  while (!(UCB2IFG&UCRXIFG));                // dummy byte TX

  x = UCB2RXBUF;

  return x;

}

 

void main( void )

{ WDTCTL = WDTPW + WDTHOLD;

  portinit();

  for (;;)

  { setCFR1_AD9951_1();

    __bis_SR_register(LPM0_bits + GIE);

   }

I have attached the connection between MSP430 and AD9951 chips

I dont have any eperience with microcontrollers so any help will be appreciated.

Thanks.

Debasish

Attachments

Outcomes