Dmitry wrote:

The same thing.

Does anybody have an experience in coupling max54xx DAC and msp430 via SPI ?

~d

The attached code is used to drive a DAC8532 using an MSP430's SPI port. This is a dual DAC. It takes 24 bit words. 16 bits are data for the 16 bit D/A. The other 8 bits are control info - select D/A A or B, update the output or just load the register, etc. Does this help?

Regards,
Steve



void setup(void)
{
    //Setup UART0 as SPI Master                                  
        ME1 |= USPIE0;                      // Enable USART0 SPI mode
        UTCTL0 = SSEL1 | SSEL0 | STC;       // SMCLK, 3-pin mode
        UCTL0 = CHAR | SYNC | MM;           // 8-bit SPI Master **SWRST**
        UBR00 = 0x02;                       // 8MHz/2 = 4MHz  
        UBR10 = 0x00;                       // 0
        UMCTL0 = 0x00;                      // no modulation
  
        //Setup I/O port for the DAC  
        P3SEL |= 0x0E;                      // P3.1-3 SPI option select
        P3DIR |= (BIT4 | BIT0);             // P3.0 output direction
                                        // P3.4 used as indicator
}

void send_to_dac (uint8_t control_byte, int16_t value)
{
        uint8_t sine_byte;
        
    P3OUT &= ~0x01;                     // Enable DAC SPI interface
    while ((IFG1 & UTXIFG0) == 0)
        /*dummy loop*/;
    TXBUF0 = control_byte;              // Send control byte
    sine_byte = (value >> 8) & 0xFF;
    while ((IFG1 & UTXIFG0) == 0)
        /*dummy loop*/; 
    TXBUF0 = sine_byte;                 // Send high byte of sinne value
    sine_byte = value & 0xFF;
    while ((IFG1 & UTXIFG0) == 0)
        /*dummy loop*/;
    TXBUF0 = sine_byte;                 // Send low byte of sinne value
    while ((UTCTL0 & TXEPT) == 0)
        /*dummy loop*/;
    P3OUT |= 0x01;                              //Whole 24 bits should be out 
on the wire by now
}

Reply via email to