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.

MSP-EXP432E401Y: SPI 32 bit communication (Uninterrupted) for BOOST-DAC8568

Part Number: MSP-EXP432E401Y
Other Parts Discussed in Thread: BOOST-DAC8568

iFor the BOOST-DAC8568, it has a 32 bit word, with the first 12 bits being control bits, followed by 16 data bits, and 4 extra bits. This is a 32 bit message. According to the part list timing diagram, it must be a 32 bit message. The Code Composer Studio SPI interface library has been previously said to only support <= 8 bit words. I tested with 16 and it kind of worked, although 32 threw an error. The obvious solution is to send multiple 8 bit messages, however according to my oscope, this results in a significant pause between bytes. Since the DAC communicates at 20MHz, it the delay ends up being almost an entire byte's size of data. Does anyone familiar with either this board or the DAC know of a solution to this? Attached is a pic of the o-scope. The yellow line is MOSI and the message sent was 01010101 01010101 01010101 01010101. The purple line is the ~SYNC pin which is currently just GPIO. Also notable, the waveform is not very rectangular. I think it could be my 200MHz oscope, but I have had problems with TI evaluation boards not supporting high frequency spi communications in the past, for now I will assume the main problem is the message timing.

I also attached the code used, although it does not seem very significant. I tried various modes as well but all had this delay or just threw an error.

[trying to use a code block gave me a server error, sorry]

// System Messages
#include <stdio.h>
#define SYS_ERROR(msg) printf("ERROR | "); printf(msg); printf("\n"); while (1) {}

#include <string.h>
#include <stdint.h>
#include <stddef.h>
#include <unistd.h>

/* Driver Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/Timer.h>
#include <ti/drivers/SPI.h>

/* Board Header file */
#include "ti_drivers_config.h"

/* Callback used for toggling the LED. */
void timerCallback(Timer_Handle myHandle, int_fast16_t status);

// SPI VARS
#define SPI_MSG_LENGTH 4
SPI_Handle spi;
unsigned char spiTxBuffer[SPI_MSG_LENGTH];
unsigned char spiRxBuffer[SPI_MSG_LENGTH];

/*
* ======== mainThread ========
*/
void *mainThread(void *arg0) {
Timer_Handle timer0;
Timer_Params params;

/* Call driver init functions */
GPIO_init();
Timer_init();
SPI_init();

/* Configure the LED pin */
GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
GPIO_setConfig(CONFIG_GPIO_LED_1, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);

GPIO_setConfig(CONFIG_GPIO_SYNC, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_HIGH);
GPIO_setConfig(CONFIG_GPIO_LDAC, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_HIGH);

/* Turn off user LED */
GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_OFF);

// SETUP SPI
SPI_Params spiParams;

/* Initialize SPI handle as default master */
SPI_Params_init(&spiParams);
spiParams.bitRate = 20000000;
spiParams.dataSize = 8;
spiParams.frameFormat = SPI_POL0_PHA0;
spi = SPI_open(CONFIG_SPI_0, &spiParams);
if (spi == NULL) {
printf("Error initializing SPI\n");
while (1);
}
else {
printf("SPI initialized\n");
}


/*
* Setting up the timer in continuous callback mode that calls the callback
* function every 1,000,000 microseconds, or 1 second.
*/
Timer_Params_init(&params);
params.period = 1000000;
params.periodUnits = Timer_PERIOD_US;
params.timerMode = Timer_CONTINUOUS_CALLBACK;
params.timerCallback = timerCallback;

timer0 = Timer_open(CONFIG_TIMER_0, &params);

if (timer0 == NULL) { SYS_ERROR("Failed to initialize timer"); }

if (Timer_start(timer0) == Timer_STATUS_ERROR) { SYS_ERROR("Failed to start timer"); }

return (NULL);
}

void timerCallback(Timer_Handle myHandle, int_fast16_t status) {
GPIO_toggle(CONFIG_GPIO_SYNC);

SPI_Transaction transaction;
bool transferOK;

//strncpy((char *)spiTxBuffer, "ffffffff", SPI_MSG_LENGTH);
//spiTxBuffer[0] = (char)(0b01110000);
//spiTxBuffer[1] = (char)(0b00001111);
//spiTxBuffer[2] = (char)(0b11111111);
//spiTxBuffer[3] = (char)(0b11110000);
spiTxBuffer[0] = (char)(0b01010101);
spiTxBuffer[1] = (char)(0b01010101);
spiTxBuffer[2] = (char)(0b01010101);
spiTxBuffer[3] = (char)(0b01010101);

printf("%c \n",spiTxBuffer[0]);

transaction.count = SPI_MSG_LENGTH;
transaction.txBuf = (void *)spiTxBuffer;
transaction.rxBuf = (void *)spiRxBuffer;
transferOK = SPI_transfer(spi, &transaction);
//if (transferOK) {printf("Message Sent... \n");}
//else {printf("Unsuccessful master SPI transfer");}

GPIO_toggle(CONFIG_GPIO_SYNC);

//Load DAC Async
GPIO_toggle(CONFIG_GPIO_LDAC);
usleep(1);
GPIO_toggle(CONFIG_GPIO_LDAC);
}