Starting Electronics needs your help! Please make a donation to help cover our hosting and other costs. Click the donate button to send a donation of any amount.
Atmel Software Framework Checklist for ARM Cortex ASF C Projects
Created on: 30 May 2016
Part 7 of the ASF ARM Tutorial
This checklist goes through the steps needed to make a new ASF project for Atmel ARM Cortex microcontrollers, which files to modify and how to add ASF modules to a project. The list is intended as a quick reference for starting new ASF projects.
Atmel Software Framework supported devices and latest documentation can be found on the Microchip ASF website.
The following steps are also available as a handy downloadable pdf file from startingelectronics on GitHub. The pdf file can be downloaded, viewed or even printed and used as a reference whenever a new ASF ARM project is created.
Books that may interest you:
Create a New ASF Project
Open Atmel Studio and start a new project using File → New → Project... from the top menu bar or Ctrl + Shift + N on the keyboard.
In the New Project dialog box, select GCC ASF Board Project, give the project a name and select the project location.
In the Board Selection dialog box enter the ARM microcontroller part number in the search field and then select User Board template for the desired microcontroller.
Select Clock Sources and Frequencies
Open the ASF Wizard using ASF → ASF Wizard from the top menu bar or Alt + W on the keyboard.
Search for clock under Available Modules in the ASF Wizard. Select System Clock Control (service) and then click the Add >> button. Click the Apply button to add the selected module.
Use Solution Explorer (image below) to open src → config → conf_board.h and add definitions for the clock resonators and oscillator start-up time, e.g.
Without these definitions the compiler will issue several warnings.
Use Solution Explorer to open src → config → conf_clock.h and comment out and uncomment the definitions to select the desired main clock source and settings.
Open src → config → conf_board.h from Solution Explorer to add hardware definitions, e.g.:
// output pin for LED
#define LED0 IOPORT_CREATE_PIN(PIOB, 14)
// input pin for switch
#define SW0 IOPORT_CREATE_PIN(PIOA, 30)
Add Board Specific Initialization Code and Initialize System Clock
Use Solution Explorer to open src → ASF → common → boards → user_board → init.c and add board specific initialization code in the board_init() function in init.c, e.g. code to disable the watchdog timer, code to set the pin direction of GPIO pins defined in conf_board.h, etc.
WDT->WDT_MR = WDT_MR_WDDIS; // disable watchdog
ioport_init(); // call before using IOPORT service
ioport_set_pin_dir(LED0, IOPORT_DIR_OUTPUT); // LED pin set as output
ioport_set_pin_dir(SW0, IOPORT_DIR_INPUT); // switch pin set as input
In the above code example, the IOPORT – General purpose I/O service (service) ASF module must be added to the project to be able to call functions starting with ioport_ in the project.
Call sysclk_init() in main.c
int main (void)
{
sysclk_init();
board_init();
while (1) {
}
}
Finally the application code for the project can be written.