EDMA on Xmega E5

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

 

I'm stumbling upon running the EDMA on XMEGA E5. Here is what I need to generate without using interrupts (it would be too slow and the signals will not switch at the same MCU cycle).

Scheme of signals

 

Initally, I used OCC4 and OCC5 to toggle pc0, pc1, pc4 and pc5, but I can't afford the timers - I need them for some other signals and procedures.

I'm trying to do it all with one timer, which in term triggers EDMA port toggling to control 4 pins, as well as two DACS. (One cycle of the long and sin signals = 20 cycles of TCD5).

 

As an input source I use TCD5 OVF, which is set correctly and works as expected.

I am trying to toggle the needed PORTC pins, but I nothing happens.

 

Here is my DMA code:

 

unsigned int portC_tgl[PWM_HALF_PER] = {0,0,0,0,0x30,0,0,0,0,0x3}; //toggle PC4 and PC5 on 5th cycle, toggle PC0 and PC1 on 10th cycle

inline void ConfigureDMA(void)
{
    EDMA.CTRL = 0;
EDMA.CTRL = EDMA_RESET_bm;
while ((EDMA.CTRL & EDMA_RESET_bm) != 0); //this passes ok
EDMA.CTRL = EDMA_ENABLE_bm | EDMA_CHMODE_STD0_gc; //ch0 is used in standard mode, 2 and 3 in peripheral

      /*******************************************************************/
     /**       SETUP CHANNEL 0 for sin signal - sound control          **/
    /*******************************************************************/

    EDMA_CH0_ADDRCTRL = EDMA_CH_RELOAD_BURST_gc | EDMA_CH_DIR_INC_gc;
    EDMA_CH0_DESTADDRCTRL = EDMA_CH_RELOAD_NONE_gc | EDMA_CH_DIR_FIXED_gc;
    EDMA_CH0_TRIGSRC   = EDMA_CH_TRIGSRC_TCD5_OVF_gc;

    EDMA_CH0_TRFCNT    = PWM_HALF_PER; //this constant is 10
    EDMA_CH0_ADDR = ((unsigned int)portC_tgl); //I've also tried ((unsigned int)&portC_tgl[0]); //this should be EDMA_CH0_SRCADDR as well, no EDMA_CH0_SRCADDR defined in icc E5 defines.
    EDMA_CH0_DESTADDR = ((unsigned int)&PORTC_OUTTGL);


    EDMA_CH0_CTRLA = EDMA_CH_REPEAT_bm;
    EDMA_CH0_CTRLA |= EDMA_CH_SINGLE_bm;
    EDMA_CH0_CTRLA |= EDMA_CH_ENABLE_bm; //I probably can do this on one pass
}

Here is how TCD5 is initialized - I've checked and it generates the expected signal:
    TCD5_CTRLB = TC45_WGMODE_SINGLESLOPE_gc;
    TCD5_CTRLC = (TC5_HCMPA_bm); //inverted polarity on OCD5A pin PD4
    TCD5_CTRLE = TC45_CCAMODE_COMP_gc;
    TCD5_INTCTRLA = 0; //no interrupts
    TCD5_PER = CHP_OUT_PERIOD;
    TCD5_CCA = CHP_OUT_HALF;
    TCD5_CTRLA = XCL_CLKSEL_DIV1_gc;

 

I tried also manually clearing TCD5 ovf interrupt flag, but it does not help.

Any help is greatly appreciated!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can't help noticing that pco/pc1 and pc4/pc5 appear to be complements so can you not generate each of those as a single signal then just pass the signal through an inverter to generate the complement signal?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yup, that is indeed true, I have it in mind, but I have spare pins so far and using inverter so far does not solve my problem with the signal generation (if I get the EDMA running toggling 2 or 4 pins on a port will be the same).

I just can't run this EDMA on E5, I use very similar code to generate sinwave for XMEGA A3U - timer triggered DAC + DMA and it works like a charm there :/

Last Edited: Mon. May 8, 2017 - 02:06 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

pnv_Creator wrote:
I just can't run this EDMA on E5, ...
fyi, XMEGA E is beta in Atmel START 2017-Apr.

Atmel START User Guide

Change Log

http://atmel-studio-doc.s3-website-us-east-1.amazonaws.com/webhelp/GUID-4E095027-601A-4343-844F-2034603B4C9C-en-US-1/index.html?GUID-DC086BFD-7DA2-43E8-8AE0-457F2351FF4C

via

http://start.atmel.com/

About

 

"Dare to be naïve." - Buckminster Fuller