ATSAMV71 how to generate sine wave via Atmel Start/ASFv4 with XDMAC and DAC0

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

Our project is using at ATSAMV71 and I need to output an audio waveform using XDMAC and one of the DAC channels.  For experimentation, I am using the ATSAMV71 Xplained Ultra board, but we will ultimately be using custom hardware.  For the moment, getting something to run on the SAMV71 Xplained board would be adequate.

 

After some searching, I found an example for Harmony that apparently generates a sine wave on DACC0 using XDMAC, but it uses very low-level calls to directly access registers and configure the XDMAC, Timer T0 and DACC0. See https://github.com/Microchip-MPLAB-Harmony/csp_apps_sam_e70_s70_v70_v71/tree/master/apps/dacc/dacc_wav_gen_dma

 

Our project is already using Atmel Start and ASFv4 to provide an abstraction layer for all of the peripherals/drivers/middleware required, and we want to keep using this framework.

 

How can I create an equivalent DMA to DAC project using Atmel Start?  I admit that I am new to Atmel Start and do not completely understand the mapping of each component and setting to underlying/equivalent CMSIS-style calls.  As an aside, we are using IAR's Embedded Workbench as our IDE/compiler/debugger, but if I can get the project configured using Atmel Start, it seems like a simple matter to export to IAR.

 

Help is greatly appreciated, and I hope will help others trying to leverage ASFv4 and previously-written examples for Harmony.

 

Thanks in advance!

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

Hi forum!

 

As a follow-up to this question, I'd like to know if there is a way to import an MPLAB Harmony project into IAR Embedded Workbench.  If I could do that, I might be able to run the example from github and gain a better understanding of exactly how the DACC (DAC0), TC (TC0), and XDMAC are being configured and used in their sine-wave via DMA example.  I can correlate some of the low-level register settings I see in the example with menu items on the Atmel Start interface, but when I look at the generated code, I don't see any initialization at all for the XDMAC controller.  I have to be missing something, and maybe others in this forum have been down this (scary) road before!

 

Many thanks for any help!

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


In the software drivers you can add a DAC driver to the project (Atmel START). There are three different drivers available, I believe async, RTOS, and sync. It seems sync is easiest to use.

 

Once you add that there is an example code generated in examples/driver_examples.c

 

/**
 * Example of using DAC_0 to generate waveform.
 */
void DAC_0_example(void)
{
	uint16_t i = 0;

	dac_sync_enable_channel(&DAC_0, 0);

	for (;;) {
		dac_sync_write(&DAC_0, 0, &i, 1);
		i = (i + 1) % 1024;
	}
}

Also, note that a refresh period may be required if you don't write to it before the timeout.

 

 

These examples provided are for the SAMD51 sync driver though, so check your datasheet for details.