DMA use for DAC with XMC_4700 Relax Lite Kit

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User16641
Level 1
Level 1
Hey everybody,

i would like to generate a SINE-WAVE with the DAC and DMA use. Unfortunately I couldn´t get it to work.
I use Dave and the XMC_4700. I want to use the XMC-Library and not the apps.

I think the problem is, that the trigger isn´t working

This is my actual Code:



#include
#include
#include
#include



#define DATA_LENGTH 120



//Instanzen
XMC_DMA_CH_CONFIG_t dma_ch_config;


//Functions
void GPDMA0_0_IRQHandler(void);


//LookUp-Table for the Sine-Wave
static uint32_t WAVE_SINE[DATA_LENGTH]= {

0x7ff, 0x86a, 0x8d5, 0x93f, 0x9a9, 0xa11, 0xa78, 0xadd, 0xb40, 0xba1,
0xbff, 0xc5a, 0xcb2, 0xd08, 0xd59, 0xda7, 0xdf1, 0xe36, 0xe77, 0xeb4,
0xeec, 0xf1f, 0xf4d, 0xf77, 0xf9a, 0xfb9, 0xfd2, 0xfe5, 0xff3, 0xffc,
0xfff, 0xffc, 0xff3, 0xfe5, 0xfd2, 0xfb9, 0xf9a, 0xf77, 0xf4d, 0xf1f,
0xeec, 0xeb4, 0xe77, 0xe36, 0xdf1, 0xda7, 0xd59, 0xd08, 0xcb2, 0xc5a,
0xbff, 0xba1, 0xb40, 0xadd, 0xa78, 0xa11, 0x9a9, 0x93f, 0x8d5, 0x86a,
0x7ff, 0x794, 0x729, 0x6bf, 0x655, 0x5ed, 0x586, 0x521, 0x4be, 0x45d,
0x3ff, 0x3a4, 0x34c, 0x2f6, 0x2a5, 0x257, 0x20d, 0x1c8, 0x187, 0x14a,
0x112, 0xdf, 0xb1, 0x87, 0x64, 0x45, 0x2c, 0x19, 0xb, 0x2,
0x0, 0x2, 0xb, 0x19, 0x2c, 0x45, 0x64, 0x87, 0xb1, 0xdf,
0x112, 0x14a, 0x187, 0x1c8, 0x20d, 0x257, 0x2a5, 0x2f6, 0x34c, 0x3a4,
0x3ff, 0x45d, 0x4be, 0x521, 0x586, 0x5ed, 0x655, 0x6bf, 0x729, 0x794
};



int main(void)
{



//DMA configuration
XMC_DMA_CH_CONFIG_t dma_ch_config =
{
.block_size=sizeof(WAVE_SINE),
.src_addr = (uint32_t)&(WAVE_SINE[0]),
.dst_addr = (uint32_t)&(DAC->DAC0DATA),
.src_transfer_width = XMC_DMA_CH_TRANSFER_WIDTH_32,
.dst_transfer_width = XMC_DMA_CH_TRANSFER_WIDTH_32,
.src_address_count_mode = XMC_DMA_CH_ADDRESS_COUNT_MODE_INCREMENT,
.dst_address_count_mode = XMC_DMA_CH_ADDRESS_COUNT_MODE_NO_CHANGE,
.src_burst_length = XMC_DMA_CH_BURST_LENGTH_8,
.dst_burst_length = XMC_DMA_CH_BURST_LENGTH_8,
.transfer_flow = XMC_DMA_CH_TRANSFER_FLOW_M2P_DMA,
.transfer_type = XMC_DMA_CH_TRANSFER_TYPE_MULTI_BLOCK_SRCADR_CONTIGUOUS_DSTADR_RELOAD,
.dst_handshaking = XMC_DMA_CH_DST_HANDSHAKING_HARDWARE,
.dst_peripheral_request = DMA0_PERIPHERAL_REQUEST_DAC_SR0_1,
.enable_interrupt = true

};


XMC_DMA_Init(XMC_DMA0);
XMC_DMA_CH_Init(XMC_DMA0, 1, &dma_ch_config);
XMC_DMA_CH_EnableEvent(XMC_DMA0,1, XMC_DMA_CH_EVENT_BLOCK_TRANSFER_COMPLETE);

/* Start DMA transfer */
// XMC_DMA_CH_SetEventHandler(XMC_DMA0, 1, dma_ch0_event_handler);
XMC_DMA_CH_Enable(XMC_DMA0,1);


/* Enable DMA event handling */
NVIC_SetPriority(GPDMA0_0_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 63, 0));
NVIC_EnableIRQ(GPDMA0_0_IRQn);




//DAC0 configuration
XMC_DAC_CH_CONFIG_t dac_handle =
{
.data_type = XMC_DAC_CH_DATA_TYPE_UNSIGNED, // es wurde unsigned datatyp ausgewählt
.output_negation = XMC_DAC_CH_OUTPUT_NEGATION_DISABLED, // Festlegen ob 4095 HIGH sind oder LOW
.output_offset = 0U,
.output_scale = XMC_DAC_CH_OUTPUT_SCALE_NONE,
};

XMC_DAC_CH_Init(XMC_DAC0, 0U, &dac_handle); // Initialisierung des DACs man muss &dac_handle machen weil die Funktion Init ein Zeiger ist, und mit & wird bestimmt wohin er zeigt
XMC_DAC_CH_StartDataMode(XMC_DAC0,0U,XMC_DAC_CH_TRIGGER_INTERNAL,100U);
//XMC_DAC_CH_EnableEvent(XMC_DAC0,0U);
//NVIC_EnableIRQ(DAC0_0_IRQn);


while(1U)
{
//Infinity LOOP
}
}


void GPDMA0_0_IRQHandler(void)
{

XMC_DMA_CH_ClearEventStatus(XMC_DMA0, 1, XMC_DMA_CH_EVENT_BLOCK_TRANSFER_COMPLETE);

}




Thank you!!


Matix
0 Likes
0 Replies