===== Debugging ===== AVR Studio 4 wants to be in debugWire mode, connect and power the badge, load a project into AVR Studio 4, compile it. Then select Debug, the first time it'll error and ask to enable debugWire mode via SPI , do this, then remove power as per instructions from AVR Studio 4. It should then connect and stop at the main function. Click Use SPI to enable debugWIRE interface
{{:start debug.png}} Click OK
{{:dw_ena.png}} Cycle the power to the badge ( remove batteries ), Click OK
{{:dw_ena1.png}} You should see something like this, if you don't make sure the power has been completely removed and reconnected.
{{:debug.png}} ===== Uploading Arduino Code ===== You can either patch into the serial pads ( two resistor 0R0 jumpers PD0/PD1 ) and upload with the arduino bootloader and IDE. Or you can just use the programmer to upload the HEX file the Arduino IDE creates. In Windows open up the TEMP folder ( go to the start/search programs and files, and type %TEMP%
{{:ard_temp.png}} Windows will open an explorer window to the temp folder. Then look for the directories that are called build__something.tmp , usually it'll be "build1215582141664046275.tmp" but the number will different, look for the one with the most recent date.
{{:temp_build.png}} Clicking on the Date modified column will make it easier to see which build folder is the most recent. Now enter that folder. There should be a .hex file with a similar name as the Arduino Project.
{{:ard_proj.png}}
See highlighted
{{:choose_hex.png}} Now load AVR Studio 4 and use the [[NULLSpace]] Kraken usbasp tool with avrdude and program that hex file to the badge. I'll detail this on a different page. Note: If you have the badge in debugWire mode, you must undo it before using a Dragon, or Kraken, othewise it will not work. See Undoing debugWIRE mode below For the AVR Dragon etc use :- Select Tools, Program AVR, Connect for the first time or Auto Connect after the options are set.
{{:select_avr.png}} Change your options as needed. Select Connect You can also use the small CON/AVR icons in the toolbar to connect/auto connect This should appear, change the options to match
{{:avr_page1.png}}
{{:avr_page2.png}}
{{:avr_page3.png}} ===== Undoing debugWIRE mode ===== If you've been debugging the badge with a Dragon ( the Kraken/usbasp/etc can't debug ), you need to turn off debugWire before you can use the regular programming tools. Open AVR Studio 4 with a suitable project, then Start debugging,I use Reset from the debug menu. Then look on the Debug menu for AVR Dragon Options If the option is greyed out, then you're either not debugging, or the CPU isn't halted in single step mode, use Reset or Break
{{:debug_opt.png}} Now click Disable debugWIRE
{{:disa_debugwire.png}} Click Yes
{{:dw_conf.npg.png}} The badge should reset, and after 4 or so seconds, this should appear, click OK.
{{:plat.png}} Finally click OK to get out of the AVR Options dialog. debugWire mode is now disabled and you can use normal ISP programmers, but obviously not debug until you re-enable debugWire.