Who am I?

Embark on a journey of self-discovery and empowerment, where you transcend beyond the confines of being merely good or bad. You are not an anomaly; you are a harmonious part of the universe, interconnected with everything else. Embrace your role as a node within an intricate network, a unique point of convergence in a vast cosmic web. This realization is your gateway to connecting with the higher self, a beacon guiding you to look beyond the surface.

Close your eyes, dive deep into the realm within, yet remember: this introspection is but one facet of existence. True reality unfolds before your very eyes, waiting to be experienced through your senses, wide open. Observing the world around you with clarity and openness is the essence of being truly alive.

To find true independence and autonomy within this network, begin by surrendering to the flow of life. Accept your role as a node. Do not seek to control or manipulate the natural course of events. Instead, let go and allow life to unfold. Welcome the energy that flows into you, embracing it with an open heart as you go about your daily life. Allow your thoughts to ebb and flow, to clash and settle, like waves returning to the sea. In this process, find rest. Sleep not just to rest the body, but to heal and rejuvenate your very essence.

As you awaken to each new day, cultivate a deep understanding and acceptance of your place in the universe. Feel the energy coursing through you, connecting you to the greater whole. You are a node within a magnificent network, a conduit for energy that flows boundlessly.

And in this journey, remember an essential truth: while thoughts may pass through you like transient visitors, the actions you perform are the true expressions of your essence. You do not possess your thoughts, but the actions you take, the energy you channel into the world—that is your true legacy.


“At the age of forty, strong and grand,
I stand, a node within life’s vibrant band.
Through me, energy’s dance is freely planned,
Part of this wondrous network, so splendid and grand.”

Tutorial 3 - Toggling LED - EVK1105

Toggling LED using delay function


For this tutorial we will be using timed delay to toggle the LED

You will need to add Delay functions and System Clock Control ASF modules.



Go to menu Project > ASF wizard and select the above mentioned modules.




 

1: #include <asf.h>
 2: 
 3: int main(void)
 4: {
 5:  sysclk_init();
 6:  delay_init(sysclk_get_cpu_hz());
 7:  gpio_configure_pin(AVR32_PIN_PB27,GPIO_DIR_OUTPUT | GPIO_INIT_HIGH);
 8:  
 9:  while(1)
10:  {
11:   gpio_tgl_gpio_pin(AVR32_PIN_PB27);
12:   delay_ms(500);
13:  }
14: }


sysclk_init() initializes the system clocks, which is required for delay functions.

delay_init() initializes delay functions. 
sysclk_get_cpu_hz() returns the cpu speed in hertz, which is required by delay_init() for the initialization.

gpio_tgl_gpio_pin toggles the gpio pin.

delay_ms() Number of millisecond to wait

Toggling LED on button press





Tutorial 4 - External Hardware Interrupts - AT32UC3A


1: __attribute__((__interrupt__))
 2: static void int_handler_port1_line0 (void)
 3: {
 4:  if( gpio_get_pin_interrupt_flag( QT1081_TOUCH_SENSOR_0 ) )
 5:  {   // PB2 generated the interrupt.
 6:   gpio_tgl_gpio_pin(LED1_GPIO);
 7:   // Clear the interrupt flag of the pin PB2 is mapped to.
 8:   gpio_clear_pin_interrupt_flag(QT1081_TOUCH_SENSOR_0);
 9:  }
10: }
11: 
12: 
13: // Main function
14: int main(void)
15: {
16:  U32 i;
17: 
18:  // Set CPU and PBA clock
19:  pcl_switch_to_osc(PCL_OSC0, FOSC0, OSC0_STARTUP);
20:  
21:  gpio_configure_pin(LED1_GPIO, GPIO_DIR_OUTPUT|GPIO_INIT_HIGH);
22:  gpio_enable_pin_interrupt(QT1081_TOUCH_SENSOR_0, GPIO_PIN_CHANGE);
23:  Disable_global_interrupt ();
24:  INTC_init_interrupts ();
25:  
26:  // register push button handler for PB2 and PB3
27:  INTC_register_interrupt( &int_handler_port1_line0, 
28:                            AVR32_GPIO_IRQ_0 + (QT1081_TOUCH_SENSOR_0/8), 0);
29: 
30:  Enable_global_interrupt ();
31:  while(true);
32: }

Tutorial 2 - Understanding General Purpose I/O of AT32UC3A using EVK1105

Introduction


AT32UC3A0 series MCU has 109 GPIO pins. Each GPIO pin can be programmed for digital input, digital output or it can be assigned to one of 3 peripheral functions, which is specific to that pin.

Example

GPIO pin 21(PA21) can be programmed to be used as general purpose digital I/O, or it can be configured for Analog input

Each GPIO line has a unique number. PA, PB, PC and PX ports do not directly correspond to the GPIO ports. To find the corresponding port and pin, the following formulas can be used:

GPIO port = floor((GPIO number) / 32), example: floor((36)/32) = 1
GPIO pin = GPIO number mod 32, example: 36 mod 32 = 4

Example: Say if LED0 is on PB27. By referring AT32UC3A0512 datasheet pg.47, we know that  GPIO number for PB27 is 59, therefore

GPIO port = floor(59/32) = 1
GPIO pin = 59 mod 32 = 27

Now lets see how the GPIO can be configured for digital out on LED1(PB28, GPIO number 60) without using ASF.


 1: #include <asf.h>
 2: 
 3: int main (void)
 4: {
 5:  
 6:  AVR32_GPIO.port[1].gpers |= 1 <<28;  //enable GPIO control
 7:  AVR32_GPIO.port[1].oders |= 1 <<28;  //enable output driver
 8:  
 9:  AVR32_GPIO.port[1].ovrc |= 1 << 28;  //clear the gpio pin
10:  
11:  while(1);
12:  
13: }


If PB28(GPIO number 60,  AT32UC3A0512 datasheet pg.47 ) i.e LED1 is to be set for digital out, we have to find GPIO port and pin for it first.
So using the formula,
GPIO port = floor(60/32) = 1
GPIO pin = 60 mod 32 = 28
We have to configure now the GPIO port 1, pin 28 for be digital out and not for peripheral function.
It is done by setting bit in gpers register. If the bit is clear, then GPIO pin will be used for peripheral function.

AVR32_GPIO.port[1].gpers |= 1 <<28;

The above line sets 28th pin on GPIO port 1. Now the pin will act as GPIO I/O

Now to set the GPIO pin 28 of port 1 as output, we have to set the 28th bit on oders(Output Driver Enable Register)
AVR32_GPIO.port[1].oders |= 1 <<28;  //enable output driver
And to set output value low, we have to set bit Output Value Register Clear(ovrc) register
AVR32_GPIO.port[1].ovrc |= 1 << 28;

Since LED is connected between vcc and the pb28, so by setting the pin low , led will turn on.

Refer pg175 of AT32UC3A datasheet for complete description of GPIO registers.



Tutorial 1 - Getting started with EVK1105

INTRODUCTION

This series of tutorial will explain how to program AT32UC3A series of microcontroller.  



Tools required for this tutorial.


1)      EVK1105/EVK1101 or any other AVR32UC3A series development board
2)      AVR Dragon or any other JTAG Debugger

3)      Atmel Strudio 6.



AVR DRAGON JTAG PIN OUTS


 

EVK1105 JTAG PIN OUTS

 

CONNECTING EVK1105 WITH AVR DRAGON


You need JTAG cable to connect EVK1105 with Avr dragon.
You can  buy Jtag cables from ebay.

http://www.ebay.com/itm/5-PCS-FC-10PIN-Flat-Ribbon-Cable-for-ISP-JTAG-space-2-54mm-length-300mm-2-5PIN-/260735643519?pt=LH_DefaultDomain_0&hash=item3cb50e2f7f


Installing atmel studio 6


Download  atmel studio from http://www.atmel.com/microsite/atmel_studio6/default.aspx 
and install it.



CONNECTING EVK1105 & AVR DRAGON TO PC

 Connect USB user of EVK1105 to the pc, to power it up and USB port of AVR Dragon to the PC. AVR Dragon doesn't provide power to EVK1105.



YOUR FIRST PROGRAM - TURNING ON LED

Atmel Studio comes with powerful framework called Atmel Software Framework(ASF).
We will be using ASF for this example, i.e to turn on LED 0 of EVK1105.
On EVK1105 LED0 is connected to GPIO(Genral purpose I/O) pin PB27.

 Here are the steps to start new project

1) Start Atmel Studio.
2) Go to menu New>Project
3) In C/C++ option on left side, choose Atmel Boards.
4) Select EVK1105 - AT32UC3A0512 and trhen click ok.

In this example we will be using GPIO Asf Module.

You can select/deselect ASF modules from menu Project>ASF Wizard

Make sure GPIO module is selected


In our first example we will be turning on the LED0 of our EVK1105 board.

LED0 is connected to vcc and GPIO pin PB27. So when GPIO Pin PB27 is high(i.e 1), the led will be off and when PB27 is low(i.e 0), the led will be on. 

 1: #include <asf.h>
 2: 
 3: int main (void)
 4: {
 5:  //LED0 is connected between vcc and GPIO Pin PB27.
 6:  gpio_configure_pin(AVR32_PIN_PB27,GPIO_DIR_OUTPUT | GPIO_INIT_HIGH);
 7: 
 8:  gpio_set_pin_low(AVR32_PIN_PB27);
 9:  
10:  while(1);
11: }
Type in the above code and compile. To load the program to MCU. go to menu Debug > Continue. IDE will ask to select Avr Dragon, select it. In few seconds code will be uploaded to mcu.
 

gpio_configure_pin() sets the GPIO pin either as output or input. By default all the gpio pin are set as input.
GPIO_DIR_OUTPUT | GPIO_INIT_HIGH parameter sets GPIO as output and sets initial state as high.