This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP432 Generate SPI Data to Feed DAC8564 ?

Other Parts Discussed in Thread: DAC8564, MSP430F449

Hello,

I want to digitize an analog signal, manipulate (curve) it, and then convert it back to analog domain for measurement purpose.

My friend and I are using MSP432P401R MCU with its ADC, and along with TI DAC8564. I need 16-bit DAC resolution so MUST use this external DAC8564. (Other MCUs with embedded DACs only provide 12-bit resolution). The ADC's function can be enabled now, but we don't know how to convert the ADC's 16-bit data to a suitable SPI format to feed DAC8564. Does anyone know how to write the code ?

We found an example code for MSP430F449 to feed a DAC8564 but couldn't work if we just apply this code to our MSP432P401R directly.

Does anyone know how to fix it ?  (The code is attached, please see "dac.c")

Thank you very much !

dac.c
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/****************************************************************/
/* FILENAME: main.c */
/* DESCRIPTION: This program uses the MSP430F449 to write 256 */
/* samples to the DAC8564/5. */
/* The samples are generated by sine/cosine functions */
/* */
/* Author: Jojo Parguian */
/* Precision Analog Applications, Dallas, TX */
/* CREATED 06/18/08(C) BY TEXAS INSTRUMENTS INCORPORATED. */
/* VERSION: 01 */
/****************************************************************/
#include <msp430x44x.h>
#include <math.h>
/**************** Function prototypes ***********************************/
/* */
void init_sys(void); /* MSP430 Initialisation routine */
void setupClock(int);
void delay(int); /* Software delay */
void dac_convert(int, int); /* Do the dac conversion */
void InitTables(int);
void int_ref_disable(int, int, int); /* Disable the Internal Reference */
void int_ref_enable(void); /* Enable the Internal Reference */
void int_ref_ON (void); /* Enable the Internal Reference */
/* all the time */
/************************************************************************/
/* */
/* HPA449 variable declarations */
/* */
/************************************************************************/
#define DAC_CS 0x20 //p3.5
#define LDAC 0x40 //p3.6
#define Resonator (0)
#define disable_ref (0)
#define enable_ref (0)
/************************************************************************/
/* */
/* main() variable declarations */
/* */
/************************************************************************/
#define BLOCK_SZ 256 /* size of data buffer */
#define TABLE_SIZE 256
int sinetable[TABLE_SIZE], costable[TABLE_SIZE], byte0, byte1, byte2;
int i, y;
/******************************************************************************\
* Function: InitTables()
* Description: Initializes Sine and Cosine Values
\******************************************************************************/
void main(void)
{
int val0, val1, val2;
int dac_A, dac_B, dac_C, dac_D;
setupClock(Resonator);
init_sys(); // Initialise the MSP430
InitTables(1); // Number defines the cycles per period
if (disable_ref)
{
val0 = 0x00;
val1 = 0x20;
val2 = 0x01;
int_ref_disable(val0, val1, val2);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • MCU : MSP432P401R
    The example code for MSP430F449 to write the DAC8564 is attached --> "dac.c"
  • just look carefully about hardware spi U of msp430, this is a very easy thing if you have read it. If still have problems, please look the wareform through oscilloscope. Finally ,why you just change you mcu for one with DAC inside ,this is very cheap and much easier.(like 6638 or 5438)
  • Thank you.
    (1) What is hardware spi "U" of MSP430 ? But what I want to trouble shoot is MSP432...
    (2) I want a DAC with 16-bit resolution. I believe there is no MCU with DAC inside provides 16-bit resolution, only 12-bit available.
  • >We found an example code for MSP430F449 to feed a DAC8564 but couldn't work if we just apply this code to our MSP432P401R directly.
    You would want to get msp432 examples regarding SPI to familiarize with SPI of particular chip, read documentation of both chips and write code or port code from mentioned ADC example msp430 code to msp432 _yourself_.

  •    

    GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_PJ, GPIO_PIN0 | GPIO_PIN1, GPIO_PRIMARY_MODULE_FUNCTION);
    CS_setExternalClockSourceFrequency(32768, 0);
    CS_initClockSignal(CS_ACLK, CS_LFXTCLK_SELECT, CS_CLOCK_DIVIDER_1);
    CS_startLFXT(CS_LFXT_DRIVE0);
    /* Selecting P1.1 P1.2 and P1.3 in SPI mode */
    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1, GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION);
    /* Configuring SPI in 3wire master mode */
    SPI_initMaster(EUSCI_A0_MODULE, &spiMasterConfig);
    /* Enable SPI module */
    SPI_enableModule(EUSCI_A0_MODULE);
    
    /* Transmitting data to slave */
    UCA0TXBUF = 0b00000000;//byte 2 to TX buffer DB23-16
    while (!(MAP_SPI_getInterruptStatus(EUSCI_A0_MODULE,EUSCI_A_SPI_TRANSMIT_INTERRUPT))); //Make sure buffer is ready before loading the next byte
    UCA0TXBUF = 0b11111110; //byte0;//byte 0 DB 15 14 13 12 11 10 9 8
    while (!(MAP_SPI_getInterruptStatus(EUSCI_A0_MODULE,EUSCI_A_SPI_TRANSMIT_INTERRUPT)));
    UCA0TXBUF = 0b11111111; //byte1;//byte DB0-13   7-6-5-4-3-2-1-0
    while((UCA0STATW&BIT0));//wait for the the busy signal to clear
    
    

**Attention** This is a public forum