View detail for Atmel AT06621: Getting Started with Atmel ATmega324PB

AVR 8-bit Microcontrollers
AT06621: Getting Started with Atmel
ATmega324PB
APPLICATION NOTE
Description
®
This application note is for getting started with the Atmel ATmega324PB
®
AVR based microcontroller.
Features
•
•
Getting started with the ATmega324PB microcontroller and tools
Getting started with Atmel ATmega324PB Xplained Pro Kit and Atmel
Studio 7
This application note contains a list of all tools required to start using
ATmega324PB and provides references for additional information.
Atmel-42626A-Getting-Started-with-Atmel-ATmega324PB_AT06621_Application Note-03/2016
Table of Contents
Description.......................................................................................................................1
Features.......................................................................................................................... 1
1. Getting Started with Atmel ATmega324PB................................................................3
1.1.
1.2.
Key Features................................................................................................................................ 3
Device Related Website Links......................................................................................................3
1.3.
1.4.
ATmega324PB Xplained Pro Kit...................................................................................................5
Atmel Studio................................................................................................................................. 7
1.4.1.
Atmel Studio Webpage ................................................................................................. 7
1.4.2.
Atmel Studio Microsite................................................................................................... 7
Connecting the ATmega324PB Xplained Pro kit.......................................................................... 7
1.5.1.
Auto Board Identification of Xplained Pro Kit ................................................................8
1.5.2.
Connect the ATmega324PB Xplained Pro UART to the EDBG COM Port....................9
1.5.
2. Creating an Example Application in Atmel Studio................................................... 10
3. What’s next?............................................................................................................ 13
4. Revision History.......................................................................................................14
Atmel AT06621: Getting Started with Atmel ATmega324PB [APPLICATION NOTE]
Atmel-42626A-Getting-Started-with-Atmel-ATmega324PB_AT06621_Application Note-03/2016
2
1.
Getting Started with Atmel ATmega324PB
1.1.
Key Features
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
AVR (Harvard) architecture
Single level pipelining
In-system reprogrammable flash memory
Separate EEPROM section available
Optional boot code section with independent lock bits
20MIPS @ 20MHz
Most single clock cycle execution
Low-power microcontroller with various sleep modes
High code density (advanced RISC Instruction Set)
On-chip hardware multiplier
Short interrupt latency four clock cycles
Factory calibrated internal RC oscillator
Security with fuses and lock bits
®
Atmel QTouch Library support
Compatibility between devices (portability)
Peripheral touch controller
Clock Failure Detection (CFD)
Note: For more information about ATmega324PB, refer to the device datasheet.
1.2.
Device Related Website Links
The ATmega324PB product webpage is available at:
http://www.atmel.com/devices/ATMEGA324PB.aspx
Atmel AT06621: Getting Started with Atmel ATmega324PB [APPLICATION NOTE]
Atmel-42626A-Getting-Started-with-Atmel-ATmega324PB_AT06621_Application Note-03/2016
3
Figure 1-1. Device Webpage
The product webpage has five tabs that provide specific information related to the device.
•
•
The Overview tab provides the basic information related to the device such as Key Parameters,
Datasheet, link to buy the device, etc.
http://www.atmel.com/devices/ATMEGA324PB.aspx?tab=overview
The Parameters tab provides the details of various configuration parameters for the device.
Atmel AT06621: Getting Started with Atmel ATmega324PB [APPLICATION NOTE]
Atmel-42626A-Getting-Started-with-Atmel-ATmega324PB_AT06621_Application Note-03/2016
4
•
http://www.atmel.com/devices/ATMEGA324PB.aspx?tab=parameters
The Documents tab provides all the related documents such as datasheet and application notes.
http://www.atmel.com/devices/ATMEGA324PB.aspx?tab=documents
–
The Datasheet section contains two types of datasheets:
Preliminary / Complete version includes all peripheral descriptions and electrical
characteristics.
Preliminary Summary / Summary version includes ordering information, pin out, and
packaging information.
–
•
•
1.3.
The Application Notes section has the device related Application Notes such as Peripheral
Usage, Getting Started, Hardware design considerations, etc. and its associated firmware (if
available).
The Applications tab provides the recommended application areas (not limited to) for this device.
http://www.atmel.com/devices/ATMEGA324PB.aspx?tab=applications
The Tools tab, all the related tools such as IDE, Programmer, Debugger, Evaluation Kits, BSDL
files are listed. This tab features the link to ATmega324PB Xplained Pro kit’s webpage.
http://www.atmel.com/devices/ATMEGA324PB.aspx?tab=tools
ATmega324PB Xplained Pro Kit
The details about ATmega324PB Xplained Pro Kit is available in the following link.
http://www.atmel.com/tools/ATMEGA324PB-XPRO.aspx
Device Ordering Information is available in the bottom section of the page.
Atmel AT06621: Getting Started with Atmel ATmega324PB [APPLICATION NOTE]
Atmel-42626A-Getting-Started-with-Atmel-ATmega324PB_AT06621_Application Note-03/2016
5
Figure 1-2. ATmega324PB Xplained Pro Webpage
Documents tab displays the kit related documents such as schematics and user guides.
http://www.atmel.com/tools/ATMEGA324PB-XPRO.aspx?tab=documents
Atmel AT06621: Getting Started with Atmel ATmega324PB [APPLICATION NOTE]
Atmel-42626A-Getting-Started-with-Atmel-ATmega324PB_AT06621_Application Note-03/2016
6
Note: For detailed information about the kit such as headers and connections, refer to ATmega324PB
Xplained Pro User Guide.
1.4.
Atmel Studio
1.4.1.
Atmel Studio Webpage
The Atmel Studio installer (free IDE) is available at:
http://www.atmel.com/tools/ATMELSTUDIO.aspx
1.4.2.
Atmel Studio Microsite
To learn more about Atmel Studio, refer to the following microsite:
http://www.atmel.com/microsite/atmel-studio/
Figure 1-3. Atmel Studio Microsite Webpage
In the Videos tab the getting started videos such as creating a new C (GCC) project, debugging AVR
®
applications, debugging ARM applications, etc. are available.
http://www.atmel.com/Microsite/atmel-studio/videos.aspx
1.5.
Connecting the ATmega324PB Xplained Pro kit
This section helps the user to connect the ATmega324PB Xplained Pro with the Atmel Studio 7.
1.
2.
3.
Download and install Atmel Studio 7 or later versions.
Launch the Atmel Studio.
Connect the ATmega324PB Xplained Pro to the USB port.It will be visible in the Atmel Studio.
Atmel AT06621: Getting Started with Atmel ATmega324PB [APPLICATION NOTE]
Atmel-42626A-Getting-Started-with-Atmel-ATmega324PB_AT06621_Application Note-03/2016
7
1.5.1.
Auto Board Identification of Xplained Pro Kit
•
®
When the ATmega324PB Xplained Pro kit is connected to the PC, the Windows Task bar will popup a message, as displayed in the following screenshot.
Figure 1-4. ATmega324PB Xplained Pro Driver Installation
•
If the driver installation is successful, EDBG will be listed in the Device Manager, as displayed in the
following screenshot.
Figure 1-5. Successful EDBG Driver Installation
•
•
Open Atmel Studio.
Go to, View > Available Atmel Tools. The EDBG should be listed in the tools as EDBG and the
tool status should display as Connected. This indicates that the tool is communicating as expected
with the Atmel Studio.
Figure 1-6. EDBG under Available Atmel Tools
Atmel AT06621: Getting Started with Atmel ATmega324PB [APPLICATION NOTE]
Atmel-42626A-Getting-Started-with-Atmel-ATmega324PB_AT06621_Application Note-03/2016
8
1.5.2.
Connect the ATmega324PB Xplained Pro UART to the EDBG COM Port
1.
2.
3.
Connect the EDBG USB to the PC.
Use the Device Manager to find the COM port number.
Default COM port settings are 9600 baud N 8 1. The COM port settings can be changed by using
the Device Manager.
Atmel AT06621: Getting Started with Atmel ATmega324PB [APPLICATION NOTE]
Atmel-42626A-Getting-Started-with-Atmel-ATmega324PB_AT06621_Application Note-03/2016
9
2.
Creating an Example Application in Atmel Studio
1.
After connecting the board, to create a new project in Atmel Studio, go to File > New > Project.
Figure 2-1. Creating New Project in Atmel Studio
2.
In the New Project wizard displayed, select the GCC C executable Project template, name the
project, and click OK to get the Device Selection wizard.
Figure 2-2. New Project Wizard
3.
The Device Selection wizard appears as shown in the following image. Select the ATmega324PB
®
device from megaAVR device family and click OK.
Figure 2-3. Device Selection Wizard
4.
The new project and the main.c file will be created as follows.
Atmel AT06621: Getting Started with Atmel ATmega324PB [APPLICATION NOTE]
Atmel-42626A-Getting-Started-with-Atmel-ATmega324PB_AT06621_Application Note-03/2016
10
Figure 2-4. Project Window
5.
Add the following code snippet (LED control using push button) in the main.c file.
int main(void)
{
/* enable the pull-up function */
MCUCR &= ~(1<<PUD);
/* enable pull-up for button */
PORTC |= 1<<PORTC6;
}
6.
/* configure LED pin as output */
DDRC |= 1<<DDRC7;
while(1)
{
/* check the button status (press - 0 , release - 1 ) */
if(!(PINC & (1<<PINC6)))
{
/*switch on the LED until button is pressed */
PORTC &= ~(1<<PORTC7);
}
else
{
/* switch off the LED if button is released*/
PORTC |= 1<<PORTC7;
}
}
Code explanation:
– Each PORT has three registers DDRx, PORTx, and PINx
– The DDRx register is used to configure the port pin direction. 1 - Output; 0 - Input
– ATmega324PB Xplained Pro kit does not have pull-ups connected and hence internal pull-up
have to be for the button. Set the MCUCR > PUD bit as logic zero to enable pull-up.
– When a pin is configured as input and the respective bit in PORTx is written logic one, the
respective pin is internally pulled up
– The PINx register is used to return the logic level available on the port pin
Atmel AT06621: Getting Started with Atmel ATmega324PB [APPLICATION NOTE]
Atmel-42626A-Getting-Started-with-Atmel-ATmega324PB_AT06621_Application Note-03/2016
11
–
7.
In the example code demonstrated Button connected to pin PC6 is configured as input with
Pull-up enabled. Pin PC7 is connected to LED0 and configured as output.
– Here the LED0 is controlled based on the Button status
– As long the button is not pressed, the LED0 will not glow and on pressing the button the LED0
will glow
To debug the project, go to Project > Properties > Tool > Selected Debugger/Programmer and
select the Tool as EDBG and Interface as JTAG.
Figure 2-5. Tool and Interface Settings
8.
To program and execute the application there are two options:
– Start a debug session on the board, where the user will be able to program and debug
– Program the generated .hex file into the controller and execute the application
Choose one of these options in Atmel Studio as shown in the following screen capture.
Figure 2-6. Start without Debugging
Figure 2-7. Start Debugging and Break
Atmel AT06621: Getting Started with Atmel ATmega324PB [APPLICATION NOTE]
Atmel-42626A-Getting-Started-with-Atmel-ATmega324PB_AT06621_Application Note-03/2016
12
3.
What’s next?
•
•
•
•
•
•
•
•
•
•
•
•
•
Atmel Studio videos
http://www.atmel.com/Microsite/atmel-studio/videos.aspx
Atmel Studio online help
http://www.atmel.com/webdoc/atmelstudio/
Atmel Studio offline help (After installing Atmel Studio)
Open Atmel Studio, Help > View Help (Ctrl+F1) > Atmel Studio
ASF (Atmel Software framework) Getting Started and ASF Reference manual
http://www.atmel.com/tools/AVRSOFTWAREFRAMEWORK.aspx?tab=documents
ASF online documentation
http://asf.atmel.com/docs/latest/
Technical documentation for various products
http://www.atmel.com/webdoc/
Atmel Gallery
https://gallery.atmel.com/
Production Selection Guide
Atmel MCU Selector on http://www.atmel.com/
Ordering Samples and Buying evaluation board and kits:
http://www.atmel.com/. Go to Buy > Atmel store
Technical Documentation
http://www.atmel.com/design-support/documentation/default.aspx
Knowledge Base and Technical Support/Design Support
http://www.atmel.com/design-support/
Collaborative workspace
http://spaces.atmel.com
®
AVR Freaks community
http://www.avrfreaks.net/
Atmel AT06621: Getting Started with Atmel ATmega324PB [APPLICATION NOTE]
Atmel-42626A-Getting-Started-with-Atmel-ATmega324PB_AT06621_Application Note-03/2016
13
4.
Revision History
Doc. Rev.
Date
Comments
42626A
03/2016
Initial document release
Atmel AT06621: Getting Started with Atmel ATmega324PB [APPLICATION NOTE]
Atmel-42626A-Getting-Started-with-Atmel-ATmega324PB_AT06621_Application Note-03/2016
14
Atmel Corporation
©
1600 Technology Drive, San Jose, CA 95110 USA
T: (+1)(408) 441.0311
F: (+1)(408) 436.4200
|
www.atmel.com
2016 Atmel Corporation. / Rev.: Atmel-42626A-Getting-Started-with-Atmel-ATmega324PB_AT06621_Application Note-03/2016
®
®
®
®
®
®
Atmel , Atmel logo and combinations thereof, Enabling Unlimited Possibilities , AVR , AVR Freaks , megaAVR , QTouch , and others are registered trademarks or
®
®
trademarks of Atmel Corporation in U.S. and other countries. ARM is a registered trademark of ARM Ltd. Windows is a registered trademark of Microsoft
Corporation in U.S. and or other countries. Other terms and product names may be trademarks of others.
DISCLAIMER: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any
intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS AND
CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED
OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS AND PROFITS, BUSINESS
INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED
OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this
document and reserves the right to make changes to specifications and products descriptions at any time without notice. Atmel does not make any commitment to
update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive
applications. Atmel products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.
SAFETY-CRITICAL, MILITARY, AND AUTOMOTIVE APPLICATIONS DISCLAIMER: Atmel products are not designed for and will not be used in connection with any
applications where the failure of such products would reasonably be expected to result in significant personal injury or death (“Safety-Critical Applications”) without
an Atmel officer's specific written consent. Safety-Critical Applications include, without limitation, life support devices and systems, equipment or systems for the
operation of nuclear facilities and weapons systems. Atmel products are not designed nor intended for use in military or aerospace applications or environments
unless specifically designated by Atmel as military-grade. Atmel products are not designed nor intended for use in automotive applications unless specifically
designated by Atmel as automotive-grade.