ATmega168PB Xplained Mini User Guide [USER GUIDE]
42381A-MCU-10/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 = ATmega168PB 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:
“Debugging the Target Using mEDBG” on page 4
.
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
Note
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.
Trying to change CKDIV8 and/or SUT_CKSEL will be prevented and an Error message will
be displayed ("One or more registers differs").
To be able to set fuses freely the ATmega32U4 EEPROM has to be programmed to 0x00
from address 0x200 to 0x214.
Note
If not exiting debug mode by selecting "Disable debugWIRE and Close" in the Debug menu,
the DWEN fuse will be enabled and the target will still be in debug mode, i.e. it will not be
possible to program the target using the SPI.
1.5.2
Debugging the Target Using mEDBG
Using the Embedded Debugger on the Xplained Mini board to debug the ATmega168PB 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.