Atmel AT32UC3
Home - Developer - Contact us





Chapter 1: Start

Chapter 2: Clocks

Chapter 3: Port

Chapter 4: Interrupt

Chapter 5: Timer

Chapter 6: Real Time

Chapter 7: Serial Link


Lecture Material

STK600UC3A3 Template


STK600 User Guide

Chapter 1

First let's see how to create a minimal project in Atmel Studio that fits our needs for a certain 32 bit processor - in this case an AT32UC3A3256S.

Open the Atmel Studio version 6.2, select 'File', 'New' and 'Project' and try to find for 'Atmel Boards' an STK600 project with a processor of the series AT32UC3A3. No luck. If you create an STK600-project with, e.g., the AT32UC3A0, you will see that there is no option to change the device to an AT32UC3A3256S on the project 'Properties' page under 'Devices': only some AT32UC3A0 and AT32UC3A1 devices are supported. If you select nevertheless the AT32UC3A3256S from the combobox 'Show devices:' under 'All Parts' you will find out that no header files will be changed. In the 'linker scripts' subdirectory still the linker script '' resides.

Let us have another try: searching for the AT32UC3A3256 gives a hit for the 'UC3 A3 Xplained - AT32UC3A256' board. If you create the project and look under project 'Properties' and 'Devices', you will indeed find the AT32UC3256S as a supported device. But the board is wrong - under the 'boards' directory you will find header files for 'uc3_a3_xplained' but not for the STK600. Also in the 'config' directory you will find a header file for the 'UC3 A3 Xplained - AT32UC3A256' board. Another dead end.

So either buy an 'UC3 A3 Xplained - AT32UC3A256' board (not a bad choice) or start thinking (sometimes a better choice): is there a template that we could adjust to our needs? Atmel Studio version 6.2 changed they way that templates were handled in version 6.1, but the possibility to use the inherent template capabilities of Microsoft Visual Studio still remain available.

The AT32UC3A3256 needs to be mounted onto the ST600-board with two adapters on top of each other: in these lectures we will use the 144-pin version of the AT32UC3A3256. Thus the routing card STK600-RCUC3A144-32 (ATSTK600-RC32) and the socket card ATSTK600-SC19 are required. For sure no elegant way to mount the processor - lots of re-routing needed with quite some wire length. This could be the reason that you don't find the template for this configuration in the Atmel Studio list. So in principle it is supported, you could even design your own adapter boards with the information supplied. You can find a list with the AT32UC3A pin mapping for the 48-pin, the 64-pi, the 100-pin and the 144-pin devices in the STK600 manual. This manual can be found in the help list of 'Atmel Studio' or with the supporting files of this lesson. The manual also contains all important information for using devices of the STK600 and for using STK600 for programming and debugging of devices. Be careful: the pin assignement of devices of different series, e.g. the UC3A0 and UC3A3 series, are very different; you need to use the right routing cards. Once you have installed it, the routing card does most of the work: the ports of the processor are mapped to the ports on the STK600 board as listed in the manual. You can use this mapping also for other functions sharing the same pin.


Directory structure of the STK600UC3A3 project.

If you intend to create your own template, read on. Otherwise download the template for projects in these lectures from the "Support Files" for this lesson and copy it into the directory 'Templates/ProjectTemplates' in your 'MyDocuments/Atmel Studio' directory. Then continue with creating your first project below in section 'First Application Program on the STK600UC3A3'.

Start with a 'User Board' template and select 'User Board - UC3 A3/A3S/A4/A4S'. This at least gives us the opportunity to specify the right processor: in the next window you can select the AT32UC3A3256S as processor. In the Atmel Studio rename the following directories and files:

This keeps us somewhat in the nomenclature of the ASF software.

Have a look at some header files :

Replace now the content of the header file 'stk600_uc3a3.h' with the content of the 'stk600_uc3a3.h'-file in the supporting files part of this lesson. This introduces the basic definitions for the clocks, LEDs and switches on the STK600 board.

We also need to add an identification for our board (-template):

Next we need to change configuration data in the 'STK600UC3A3.cproj'-file, an XML-file that specifies files and their location and parameters for compiling and linking of the project files.

In the 'Release'-part of the <ToolchainSettings> the following changes should be done: In the 'Debug'-part of the <ToolchainSettings> the following changes should be done:

Finally change the include file statement #include user_board.h/user_board.h in asf.h and save the project as STK600UC3A3.

When you installed Atmel Studio, it created a directory structure under 'AtmelStudio' in your 'MyDocuments' directory. This directory structure contains a 'Template'- and a 'My Exported Templates'-directory together with a number of other directories for example projects and default storage for user projects in the directory '6.2'. Templates in the 'Template\ProjectTemplates'-directory are automatically loaded and show up when a 'New Project' wizzard is started (under C/C++ projects).

In a last step to create the template, we use the "Export Template' feature of Atmel Studio:

Proceed to the next page of the wizzard.

Top-level structure of the STK600UC3A3 zip-file.

After clicking 'Finish', an explorer window will open (as selected before in the wizzard). It shows the content of the 'My Exported Templates' folder. You can inspect your new template there as zip-file ''. The high-level structure of the zip-file is shown in the Figure.

This finishes the preparation of the template. If you create a new project you will find the template on the first page of the 'New Project'-wizzard if you select 'C/C++' of 'Installed Templates'.

First Application Program on the STK600_UC3A3

Create a new project in Atmel Studio, select STK600_UCA3 as template and name it Application_1. This will be a very basic project that just sequentially lights up one LED after the other, We will not specify any clock settings: by default the slow RC-clock with a frequency of about 115kHz is used on chip.

First we enable the parallel outputs to the LED-ports specified in the 'stk600_uc3a3.h' header file.:

	// Enable LEDs Port 0 and pins A24 to A31
	AVR32_GPIO.port[LED_PORT].gpers = 1 << LED0_GPIO;
	AVR32_GPIO.port[LED_PORT].gpers = 1 << LED1_GPIO;
	AVR32_GPIO.port[LED_PORT].gpers = 1 << LED2_GPIO;
	AVR32_GPIO.port[LED_PORT].gpers = 1 << LED3_GPIO;
	AVR32_GPIO.port[LED_PORT].gpers = 1 << LED4_GPIO;
	AVR32_GPIO.port[LED_PORT].gpers = 1 << LED5_GPIO;
	AVR32_GPIO.port[LED_PORT].gpers = 1 << LED6_GPIO;
	AVR32_GPIO.port[LED_PORT].gpers = 1 << LED7_GPIO;

Next we switch on the output drivers on these pins:

		// Enable output drivers
	AVR32_GPIO.port[LED_PORT].oders = 1 << LED0_GPIO;
	AVR32_GPIO.port[LED_PORT].oders = 1 << LED1_GPIO;
	AVR32_GPIO.port[LED_PORT].oders = 1 << LED2_GPIO;
	AVR32_GPIO.port[LED_PORT].oders = 1 << LED3_GPIO;
	AVR32_GPIO.port[LED_PORT].oders = 1 << LED4_GPIO;
	AVR32_GPIO.port[LED_PORT].oders = 1 << LED5_GPIO;
	AVR32_GPIO.port[LED_PORT].oders = 1 << LED6_GPIO;
	AVR32_GPIO.port[LED_PORT].oders = 1 << LED7_GPIO;

Finally we switch on one LED and switch off the previous one - remember: a low output switches the LEDs on! As delay we simply use a loop: we count to 1000 until we proceed to the next LED. Counting to 1000 is sufficient with the low clock frequency of 115kHz.

	while (true) {
		switch (lcount) {
			case 0:
				AVR32_GPIO.port[LED_PORT].ovrs = 1 << LED7_GPIO;
				AVR32_GPIO.port[LED_PORT].ovrc = 1 << LED0_GPIO;
			case 1:
				AVR32_GPIO.port[LED_PORT].ovrs = 1 << LED0_GPIO;
				AVR32_GPIO.port[LED_PORT].ovrc = 1 << LED1_GPIO;
			case 2:
				AVR32_GPIO.port[LED_PORT].ovrs = 1 << LED1_GPIO;
				AVR32_GPIO.port[LED_PORT].ovrc = 1 << LED2_GPIO;
			case 3:
				AVR32_GPIO.port[LED_PORT].ovrs = 1 << LED2_GPIO;
				AVR32_GPIO.port[LED_PORT].ovrc = 1 << LED3_GPIO;
			case 4:
				AVR32_GPIO.port[LED_PORT].ovrs = 1 << LED3_GPIO;
				AVR32_GPIO.port[LED_PORT].ovrc = 1 << LED4_GPIO;
			case 5:
				AVR32_GPIO.port[LED_PORT].ovrs = 1 << LED4_GPIO;
				AVR32_GPIO.port[LED_PORT].ovrc = 1 << LED5_GPIO;
			case 6:
				AVR32_GPIO.port[LED_PORT].ovrs = 1 << LED5_GPIO;
				AVR32_GPIO.port[LED_PORT].ovrc = 1 << LED6_GPIO;
			case 7:
				AVR32_GPIO.port[LED_PORT].ovrs = 1 << LED6_GPIO;
				AVR32_GPIO.port[LED_PORT].ovrc = 1 << LED7_GPIO;
		// delay by counting
		count = 0;
		while (count < 1000) {
		if (lcount > 7) lcount = 0;

Connect port D on the STK600 with the LED-port, set the optimization level to 'None (-O0)' in the project properties (Toolchain tab), compile the little program (the complete listing is in the Lession Material section) and load it onto the STK600 board. The LEDs should start 'running' immediately.