Atmel ATmega328P Xplained Mini MEGA328P-XMINI MEGA328P-XMINI Data Sheet

Product codes
MEGA328P-XMINI
Page of 16
 
ATmega328P Xplained Mini User Guide [USER GUIDE]
42287A-MCU-05/2014
4
1.5
Programming and Debugging
How to program and debug the Xplained Mini board.
1.5.1
Programming the Target Using mEDBG
Using the Embedded Debugger on the Xplained Mini board to program the ATmega328 via the SPI bus.
1. Connect the mEDBG USB to the PC.
2. Go to Atmel Studio: click Tools, select Device Programming, and select the connected mEDBG as Tool
with Device = ATmega328P and Interface = ISP, click Apply. Note that if ISP programming fails it could
be because debugWIRE is enabled. See debugging chapter on how to disable debugWIRE mode:
3. Select "Memories" and locate the source hex or elf file and click Program.
4. If the source contains fuse settings go to "Production file" and upload the elf file and program the fuses.
5. To set fuses manually click Fuses and select the setting.
Recommended fuse setting:
BOOTSZ = 1024W_1C00,
BOOTRST = [ ],
RSTDISBL = [ ],
DWEN = [ ],
SPIEN = [X],
WDTON = [ ],
EESAVE = [ ],
BODLEVEL = DISABLE,
CKDIV8 = [ ],
CKOUT = [ ],
SUT_CKSEL = EXTCLK_6CK_14CK_65MS
Important
If any other cpu clk than the external clk supplied by the mEDBG is used the debugWIRE is
not guaranteed to work.
The mEDBG will prevent writing certain fuse combinations in order to protect your kit.
1.5.2
Debugging the Target Using mEDBG
Using the Embedded Debugger on the Xplained Mini board to debug the ATmega328P via debugWIRE.
1. Start Atmel Studio.
2. Connect the mEDBG USB to the PC.
3. Open your project.
4. In the Project menu select the project properties page, select the Tools tab and select mEDBG as
debugger and debugWIRE as interface.
5. In the Debug menu click Start Debugging and Break.
6. Atmel Studio will display an error message if the DWEN fuse in the ATmega328P is not enabled, click YES
to make Studio set the fuse using the ISP interface.
7. A debug session is started with a break in main, debugging can start.
8. When exiting debug mode select "Disable debugWIRE and Close" in the Debug menu, this will disable the
DWEN fuse.