How to start timer using DMA

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

Hi, I am working on codes for xmega256a3bu chip and a plan is to start TCC0 timer using DMA via. Event sytem like this.

ACB.CH0 (analog comparator) => Event CH1 => DMA.CH2 => TCC0.CTRLA (clk source: Event CH0)

DMA.CH2 provides 0x08 value (Event CH0) to TCC0.CTRLA to start it.

I am using ASF and the actual codes are as below.

The problem is that TCC0.CTRLA is never written 0x08 hence, TCC0 never starts.

I created an interrupt routine to toggle IO pin to check ACB.CH0's output changes as it reacts to input signal change, and I confirmed it is working.

The next thing I did was to swap the source and destination address to see if TCC0.CTRLA value (in this case it is 0x00) is written to tcc0Start (data array).

Then I found DMA put 0x00 value to tcc0Start. So DMA is also seems to be working. Yet, I am not able to write CTRLA register.

I appreciate your help on this matter. Thank you in advance. 

 

memset(&dmach_conf, 0, sizeof(dmach_conf));
 dma_channel_set_burst_length(&dmach_conf, DMA_CH_BURSTLEN_1BYTE_gc);  //
 dma_channel_set_transfer_count(&dmach_conf, 1);        //
 dma_channel_set_src_reload_mode(&dmach_conf,DMA_CH_SRCRELOAD_NONE_gc);  //
 dma_channel_set_dest_reload_mode(&dmach_conf, DMA_CH_DESTRELOAD_NONE_gc); //
 dma_channel_set_src_dir_mode(&dmach_conf, DMA_CH_SRCDIR_FIXED_gc);
 dma_channel_set_dest_dir_mode(&dmach_conf, DMA_CH_DESTDIR_FIXED_gc);
 dma_channel_set_source_address(&dmach_conf, (uint16_t)(uintptr_t)&tcc0Start);
 dma_channel_set_destination_address(&dmach_conf, (uint16_t)(uintptr_t)TCC0.CTRLA);
 dma_channel_set_trigger_source(&dmach_conf,  DMA_CH_TRIGSRC_EVSYS_CH1_gc);
 dma_channel_set_single_shot(&dmach_conf);
 dma_enable();
 dma_channel_write_config(dmaChannel2, &dmach_conf);  

 

The below code is written in another function to start DMA.

DMA.CH2.CTRLA|=0xa<<4; // this start DMA.CH2 (dmaChannel2)

 

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

Looks like you are missing an "address of" operator for the destination, I expect it should would be: 
 

dma_channel_set_destination_address(&dmach_conf, (uint16_t)(uintptr_t)&TCC0.CTRLA);

/Lars

Last Edited: Sun. Mar 22, 2015 - 09:39 PM