Let's begin with a small project that turns on a LED on the board.
To start a new project, click File > New > Project... or press Clrl + Shift + N.
Select GCC C ASF Board Project and name the project as ledtest.
In the right-hand side, you'll find the Solution Explorer window. Open the src folder, and double-click main.c. This is where we will be doing most of the programming.
In the Solution Explorer, open
src > boards > sam4s_ek2 > sam4s_ek2.h
This header file lists several definition related to the board operating frequency and board description. Lets try to find an LED pin in this header file.
Let us now go to main.c file and try to find a gpio function that will turn the LED pin on and off.
By typing gpio, a number of suggestion pop-up. Select gpio_set_pin_low. This function takes a gpio pin as an argument. So paste LED0_GPIO as the argument.
gpio_set_pin_low(LED0_GPIO);
Give an infinite loop such as
while(true) {}
To compile and build the project, go to Build > Compile and Build > Build Solution. If there is no error, Build succeeded message will appear in your output windows. Output file will be created in your project folder as a binary package.
To flash the board
Now the blue led turn on.