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.

DMA error code: 1 DMA error!!

Other Parts Discussed in Thread: SYSBIOS

Hi, I have tried editing the "spiloopback_EK_TM4C1294XL_TI_TivaTM4C1294NCPDT" project to be able to output values to a 10-bit DAC. The example code sends a string but I am needing to send 16-bits in total in a continuous loop. Since trying to bit shift and mask the values needed to be sent I have been getting a 'DMA error code: 1. Below is my code. Any suggestions or ideas would be greatly appreciated. Thanks.

#include "stdbool.h"
#include "stdint.h"
#include "stdlib.h"
#include "math.h"
#include "float.h"
#include "stdio.h"

/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/runtime/System.h>

/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>

/* TI-RTOS Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/SPI.h>

/* Example/Board Header files */
#include "Board.h"

#define SPI_MSG_LENGTH 1
#define TASKSTACKSIZE 76800

Task_Struct task0Struct;
Char task0Stack[TASKSTACKSIZE];
int16_t masterRxBuffer;
int16_t masterTxBuffer;
/*
* ======== masterTaskFxn ========
* Task function for master task.
*
* This task runs at a lower priority after the slave
* task to ensure it is ready for a transaction.
* Master SPI sends a message to slave and also
* receives message from slave. Task for this function
* is created statically. See the project's .cfg
* file.
*/

void masterTaskFxn (UArg arg0, UArg arg1) {

int16_t ranTable[4096];
int16_t sawTable[4096];
int16_t squTable[4096];
int16_t triTable[4096];
int16_t sinTable[4096];
int i = 0;
int j = 0;
int k = 0;

SPI_Handle masterSpi;
SPI_Transaction masterTransaction;
bool transferOK;

// Create sawtooth wave look up table
for (i = 0; i < 4096; i++) {
if (j == 4) {
j = 0;
k++;
}
sawTable[i] = k;
j++;
}

// Create square wave look up table
for (i = 0; i < 4096; i++) {
if (i < 2048)
squTable[i] = 0;
else
squTable[i] = 1023;
}

// Reset counters
j = 0;
k = 0;

// Create triangular wave look up table
for (i = 0; i < 4096; i++) {
if (j == 2) {
j = 0;
k++;
}
if (k < 1024)
triTable[i] = k;
else
triTable[i] = 2047 - k;
j++;
}

// Create sine wave look up table
for (i = 0; i < 4096; i++)
sinTable[i] = (((sin((i*2*3.14)/4096))*512) + 512);

// Create random noise look up table
for (i = 0; i < 4096; i++)
ranTable[i] = (rand() % 1023);

i = 0;

while (1) {

if (i == 4096)
i = 0;

masterTxBuffer = ((ranTable[i] << 2) | 0x3000);
System_printf("%d\n", masterTxBuffer);

/* Initialize SPI handle as default master */
masterSpi = SPI_open(Board_SPI0, NULL);

/* Initialize master SPI transaction structure */
masterTransaction.count = 1;
masterTransaction.txBuf = (Ptr)masterTxBuffer;
masterTransaction.rxBuf = (Ptr)masterRxBuffer;

/* Initiate SPI transfer */
transferOK = SPI_transfer(masterSpi, &masterTransaction);

if (transferOK)
System_printf("Master receive OK. Sent: %d\n", masterTransaction.txBuf);
else
System_printf("Unsuccessful master SPI transfer\n");
i++;

/* Deinitialize SPI */
SPI_close(masterSpi);

/* SysMin will only print to the console when you call flush or exit */
System_flush();
}
}

//======== main ========
void main(void) {

/* Construct BIOS objects */
Task_Params taskParams;

/* Call board init functions. */
Board_initGeneral();
Board_initGPIO();
Board_initSPI();

/* Write CS HIGH */
//GPIO_write(Board_LED0, Board_LED_ON);

/* Write CS LOW */
//GPIO_write(Board_LED0, Board_LED_ON);

/* Construct master/slave Task threads */
Task_Params_init(&taskParams);
taskParams.priority = 1;
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task0Stack;
Task_construct(&task0Struct, (Task_FuncPtr)masterTaskFxn, &taskParams, NULL);

/* Turn on user LED */
GPIO_write(Board_LED0, Board_LED_ON);

/* Start BIOS */
BIOS_start();
}