Description
This package provides access to the Atmel XDMAC (Extended DMA Controller) devices. This support is not intended to expose the full functionality of these devices. It is mainly limited to supporting peripheral DMA (e.g. USART, SPI, etc.). It is currently limited to single DMA transfers.
There is currently no cross-platform/variant standardised eCos DMA I/O interface package, since DMA features and functionality vary greatly between architectures, and event within variants of an architecture. Roes theory of personality development and career choice pdf. This stand-alone device package allows common DMA support to be shared between devices that implement Atmel DMA Controllers.
Description: The application note introduces Atmel-ICE setup, driver installation, user guide of the Atmel Studio command line utility (atprogram.exe), and provide a PC programming tool project written in C#. The Visual C# example project can be downloaded along with this application note and run with the ATmega328PB Xplained Mini kit. These notes describe how to program a SAMD21 breakout board with the Atmel ICE, using the command line on Mac OS X or Linux Debian, without Atmel Studio or any other IDE, or even any hardware abstraction library. This updates a previous blog entry with more details and minor corrections. Atmel-ICE on MacOS X. GitHub Gist: instantly share code, notes, and snippets.
Manuals and User Guides for Atmel Atmel-ICE. We have 2 Atmel Atmel-ICE manuals available for free PDF download: User Manual Atmel Atmel-ICE User Manual (62 pages). ATMEL AVR USB DRIVER FOR MAC. Ide atmel studio studio, avr programming device. Default atmel studio, usb controller raspi. Usb device atmel firmware. Buy atmel avr usb. Download atmel studio, integrated development environment atmel. Usb circuit atmega8, read atmel avr usb, atmel avr usb. Avr jungo usb software, free download avr jungo.
The user is directed towards the relevant Atmel documentation for a full description of the XDMAC devices, and to the variant device drivers for examples of the use of this API. This documentation only gives a brief description of the functions available.
The API of this controller is designed to be compatible with that for the Atmel DMAC controller and is a drop-in replacement for it. Thus the API refers to the DMAC in its naming, not the XDMAC.
A XDMAC instance is defined by a controller number (0 or 1), and each controller has support for a number of (variant defined) channels. The API uses a simple 32-bit encoding to describe how a specific DMA channel should be used, with this package providing helper macros to combine the necessary information into a unique descriptor. These descriptors may be stored with a device driver as required.
The following are examples of how definitions can be made:
Before DMA transfers can be performed, a DMA channel must be claimed. This is done by calling atmel_dmac_chan_alloc()
. The descriptor
argument describes the majority of the DMA transfer configuration that will be used. As shown in the examples above the passed descriptor not only encodes the source and destination interfaces, but also the transfer sizes. Also, depending on the descriptor construction macros used, it is possible to control the direction and modification of addresses during transfers. The cb
argument is used to register a client function that will be called when a requested transfer completes. The priv
argument is a client specified value that will be passed to the callback function, and can be used to reference client driver specific data.
The atmel_dmac_chan_config()
Windows toolkit free download. function is present for compatibility with the DMAC driver. It is not currently needed, but device drivers that may use both drivers may call this with not effect.
Most drivers will allocate a DMA channel object and keep it active throughout the system lifetime. However, if it is necessary to share a channel, or otherwise disable the use of a stream, the driver may call atmel_dmac_chan_free()
to return a channel to an unused state. It will be necessary to call atmel_dmac_chan_alloc()
before specific DMA descriptor operations can be performed again.
The register callback function has the following prototype:
The ch
is the channel structure describing the transfer. The cbid
argument is a completion identifier:
Table 110.1. Completion Codes
CYGHWR_ATMEL_DMA_COMPLETE | A valid transfer completion. The count argument should match the size passed to the atmel_dmac_start() call. |
CYGHWR_ATMEL_DMA_AHBERR | This code indicates that the DMA Controller has detected an AHB read or write access error. This may indicate invalid memory addresses have been passed, or invalid AHB_IF mappings have been used. |
CYGHWR_ATMEL_DMA_DICERR | For configurations where Descriptor Integrity Check support is available, and enabled, then if an error is detected in a referenced memory-based transfer structure this result will be raised. |
The count
argument is the number of data items successfully transferred. The data
argument is the client private data registered for the callback.
A transfer is configured and started by calling atmel_dmac_start()
. The ch
argument describes the DMA channel, with the descriptor used when allocating the channel defining how the other arguments are used. The src
argument defines the peripheral or memory address from which the transfer will be made. The dst
argument supplies the peripheral or memory address to which the transfer will write. The size
argument defines the number of data items to be transferred. Once this function call completes the channel is operational and will transfer data once the relevant peripheral starts triggering transfers.
When the transfer completes the registered callback is called from DSR mode.
Notes: |
---|
|
Work from the command line on OS X or Linux, without Atmel Studio or Eclipse -- Updated article.
October 6, 2017
These notes describe how to program a SAMD21 breakout board with the Atmel ICE, using the command line on Mac OS X or Linux Debian, without Atmel Studio or any other IDE, or even any hardware abstraction library. This updates a previous blog entry with more details and minor corrections.
To illustrate SAMD21 programming, we will use a Sparkfun SAMD21 dev breakout board as our target. It features the popular Atmel SAMD21G18 ARM Cortex M0 and our examples should work with little or no modifications on similar platforms such as the Arduino M0 or the TAU featured in the previous version of this article.
In terms of hardware, this article also assumes you own an Atmel ICE programmer.
You will need to install some software packages to program your SAMD21 board. On Debian Linux, you will use your package manager (e.g. 'aptitude'). On the Mac, we suggest using homebrew to install the different tools described here.
Most drivers will allocate a DMA channel object and keep it active throughout the system lifetime. However, if it is necessary to share a channel, or otherwise disable the use of a stream, the driver may call atmel_dmac_chan_free()
to return a channel to an unused state. It will be necessary to call atmel_dmac_chan_alloc()
before specific DMA descriptor operations can be performed again.
The register callback function has the following prototype:
The ch
is the channel structure describing the transfer. The cbid
argument is a completion identifier:
Table 110.1. Completion Codes
CYGHWR_ATMEL_DMA_COMPLETE | A valid transfer completion. The count argument should match the size passed to the atmel_dmac_start() call. |
CYGHWR_ATMEL_DMA_AHBERR | This code indicates that the DMA Controller has detected an AHB read or write access error. This may indicate invalid memory addresses have been passed, or invalid AHB_IF mappings have been used. |
CYGHWR_ATMEL_DMA_DICERR | For configurations where Descriptor Integrity Check support is available, and enabled, then if an error is detected in a referenced memory-based transfer structure this result will be raised. |
The count
argument is the number of data items successfully transferred. The data
argument is the client private data registered for the callback.
A transfer is configured and started by calling atmel_dmac_start()
. The ch
argument describes the DMA channel, with the descriptor used when allocating the channel defining how the other arguments are used. The src
argument defines the peripheral or memory address from which the transfer will be made. The dst
argument supplies the peripheral or memory address to which the transfer will write. The size
argument defines the number of data items to be transferred. Once this function call completes the channel is operational and will transfer data once the relevant peripheral starts triggering transfers.
When the transfer completes the registered callback is called from DSR mode.
Notes: |
---|
|
Work from the command line on OS X or Linux, without Atmel Studio or Eclipse -- Updated article.
October 6, 2017
These notes describe how to program a SAMD21 breakout board with the Atmel ICE, using the command line on Mac OS X or Linux Debian, without Atmel Studio or any other IDE, or even any hardware abstraction library. This updates a previous blog entry with more details and minor corrections.
To illustrate SAMD21 programming, we will use a Sparkfun SAMD21 dev breakout board as our target. It features the popular Atmel SAMD21G18 ARM Cortex M0 and our examples should work with little or no modifications on similar platforms such as the Arduino M0 or the TAU featured in the previous version of this article.
In terms of hardware, this article also assumes you own an Atmel ICE programmer.
You will need to install some software packages to program your SAMD21 board. On Debian Linux, you will use your package manager (e.g. 'aptitude'). On the Mac, we suggest using homebrew to install the different tools described here.
Step 1: Install the programming header
To program a SAMD21 board with OpenOCD you will need to connect that programmer to your board with the SWD header. On the Sparkfun SAMD21 breakout board this SWD header is present but unpopulated as shown in the picture below, on the left. You will need to fit a 2x5 pin 1.27mm male header, as shown in the picture below, on the right.
You don't necessarily need to solder the header to the board: just plugging the header is usually good enough to establish electrical contact.You will then plug the corresponding connector on the Atmel ICE. Since the connector is not keyed, there are two possible ways to plug the Atmel ICE on the board. If you try one way and it doesn't work, just flip the connector around!
Step 2: Install the C compiler for ARM
The ARM developer tools (arm-none-eabi) need to be installed on your system.
On the Mac, with homebrew, it boils down to one command:
On a Linux, with a Debian style OS, you will need to refer to your package manager (apt-get or aptitude).
Step 3: Install OpenOCD
Installing OpenOCD on the Mac is also a one-liner:
On Debian Linux, a similar aptitude install openocd
will do the trick.
Once installed, the next step is to set up OpenOCD correctly. For this purpose create a file called openocf.cfg, with the following content:
You should change the value at91samd21g18 to match the microcontroller you are using.
You can test your openocd.cfg
file by simply typing openocd
. You should get an output similar to this:
Now you can plug the SWD header in the board you want to program. Don't forget to power the board separately, with USB for example. If you launch OpenOCD again, you should get the following output:
If this fails, you may have plugged the SWD connector backward: just flip it around.
Now, while OpenOCD is still running, we can test that gdb works by typing arm-none-eabi-gdb -iex 'target extended-remote localhost:3333' in another terminal window:
If you got this far, your OpenOCD is complete.
Step 4: Writing code to blink an LED
The Sparkfun SAMD21 breakout board has an LED on the pin labeled 'D13', which maps to the GPIO PA17: the 17th io port on port A. We will make it blink to test our setup.If you have another board it might have an LED on a different PIN or none at all, you will need to adapt the code below (e.g. the SAMD21 Xplained pro has an LED on PB30).
In the code above, blinking the LED PA17 is achieved by setting and clearing the 17th bit of a specific register called REG_PORT_DIR0
, which corresponds to port A on the SAMD21. There are in fact several ways to achieve the same result on the SAMD21, we are just showing one for simplicity.
To compile this file, you will need a set of headers provided by Microchip/Atmel. First, download the Atmel Software Framework (ASF) from http://www.microchip.com/avr-support/advanced-software-framework-(asf). In fact, you will only be using a very small subset of this big framework, and you will be able to delete a large part of this framework if needed later.
When uncompressing the file, you'll get a directory named xdk-asf-3.37/
or something similar depending on the version you downloaded. Let's name ASF_ROOT the absolute path corresponding to that directory (e.g. set ASF_ROOT='/Users/pannetra/Src/xdk-asf-3.37'
).
Go to the directory where you put the openocd.cfg file and perform the following actions:
Now the following steps will need a small customization depending on the microcontroller you have. In the case of our Sparkfun board, it's a SAMD21G18A:
If you have a different microcontroller from the SAMD21G18A, you should change the file name samd21g18a_flash.ld to match your microcontroller.
The above Makefile is derived from the great work of Geoffrey Brown on the STM32.
If you have a different microcontroller from the SAMD21G18A, you need to change the following two lines in the Makefile: LDSCRIPT = samd21g18a_flash.ld
and PTYPE=__SAMD21G18A__
, replacing references to the samd21g18a with your own.
Step 5: Compiling and running the code
If you followed all the steps above, you should have the following files in your current directory:
- Makefile
- openocd.cfg
- startup_samd21.c
- main.c
- samd21g18a_flash.ld
We will check that the code compiles as expected.
Now, you are ready to run the program. Connect the Atmel ICE and power your board. Launch OpenOCD as shown previously. In a separate terminal window, we will use gdb to load the program and run it:
Note the gdb commands:
- load uploads the code to the SAMD21
- monitor reset halt resets the SAMD21
- c starts running the code (c is short of continue)
At this point, your LED should blink!
Comments
HI, I was just wondering. I already have the Atmel Power Debugger. How could i use it with this setup, instead of an Atmel ICE?
berkut3000, almost 2 years agoI used this as a guide on Ubuntu 19.04, and found that I had to make the following adaptations: use gdb-multiarch instead of arm-none-eabi-gdb, and change the Makefile debug section to: gdb-multiarch -ex 'target extended-remote localhost:3333' $(ELF). This was a very useful guide to getting everything working, thanks.
Austin Gosling, about 1 year agoThank you for posting this, I have been trying to do this for a while, and your instructions were extremely helpful in sending me in the right direction.
Nathan