ZeptoProg User Guide
ZeptoProg User Guide
ZeptoProg User Guide
June11,2011
http://www.mattairtech.com/
ZeptoProg
UserGuide
Table of Contents
Overview........................................................................................................................4
Introduction............................................................................................................... ........................4
4toolsin1................................................................................................................................... ......4
Features............................................................................................................................... .............6
About..............................................................................................................................7
ContactInformation............................................................................................................... ............7
SupportInformation......................................................................................................................... ..7
Precautions.................................................................................................................... ...................7
WindowsInstallation....................................................................................................8
WinAVR/AVRDUDE..................................................................................................................... ....8
AVRStudio/AVRISPmkIIdriver....................................................................................................... .9
FLIP/DFUBootloaderDriver................................................................................................ ..........10
ZeptoProgDriver/SerialConfiguration................................................................... ........................11
TerminalEmulator............................................................................................. ..............................13
LinuxInstallation........................................................................................................14
Drivers............................................................................................................................... ..............14
GCCToolchain........................................................................................................... .....................14
AVRDUDE...................................................................................................................... .................14
dfuprogrammer........................................................................................................................ .......14
TerminalEmulator............................................................................................................................ 14
ZeptoProgHardware...................................................................................................15
Layout/HeaderPins..................................................................................................... ..................15
PinDescriptions................................................................................................. .............................16
Buttons........................................................................................................................ ....................17
LEDs.................................................................................................................... ...........................18
Configuration..............................................................................................................19
AVRProgrammer........................................................................................................20
Configuration........................................................................................................................... ........20
ConnectingTargetBoard............................................................................................................... ..20
UsingAVRStudio.................................................................................................................. ..........21
UsingAVRDUDE....................................................................................................................... ......25
GPIOApp.....................................................................................................................26
GPIOAppConfiguration............................................................................................................... ...26
GPIOPinConnections............................................................................................. .......................27
PinConfiguration...................................................................................................................... .......27
TimerConfiguration................................................................................................................... ......28
Input................................................................................................................................... .............29
Output........................................................................................................................ .....................29
PWM........................................................................................................................... ....................30
June11,2011
http://www.mattairtech.com/
ZeptoProg
UserGuide
FrequencyOutput.......................................................................................................................... ..32
FrequencyMeasurement............................................................................................................... ..33
SerialApp....................................................................................................................35
SerialAppConfiguration..................................................................................... ............................35
SerialConnections......................................................................................................... .................36
SPIApp........................................................................................................................37
SPIAppConfiguration.......................................................................................................... ...........37
SPIConnections.............................................................................................................................. 37
SPICommands................................................................................................................ ...............38
SPITransfer........................................................................................................... .........................38
SPIWrite.......................................................................................................................... ...............39
SPIRead................................................................................................................................... ......39
ExampleSession.............................................................................................. ..............................40
DFUBootloader...........................................................................................................41
FLIP............................................................................................................................................. ....41
dfuprogrammer................................................................................................. .............................43
LegalNotices..............................................................................................................44
CopyrightNotices................................................................................................................ ............44
SoftwareDisclaimer................................................................................................ ........................44
HardwareDisclaimer........................................................................................................ ...............44
Trademarks............................................................................................................... ......................44
Acknowledgments......................................................................................................... ..................44
AppendixA:PoweringTargetviaZeptoProg5V.....................................................45
AppendixB:AVRProgrammerSupportedDevices................................................46
June11,2011
http://www.mattairtech.com/
ZeptoProg
UserGuide
Overview
Introduction
TheZeptoProgisanAVRISPmkIIcompatibleUSBAVRprogrammerthatsupportsallchips
withtheISP,PDI,orTPIprogramminginterfaces.TheseincludemostmegaAVR,tinyAVR,and
XMEGAseriesdevices.Standard6pinheadersareusedforISPandPDI.Itsupportshighspeed
insystemprogrammingoftheAVRflash,EEPROM,fuses,lockbits,andmoreusingAVRStudioor
AVRDUDE.Targetboardsoperatingat2Vto5Varesupported.Anoptionalrecoveryclockcanbe
usedasaclocksourceforthetarget.Additionally,threeutilitiesareprovidedthatareusefulfor
developmentanddebugging.TheUSBtoserialbridgecanbeusedtoconnectthetarget,atupto
2MHzbaudrate,toacomputerfordebuggingoutputorgeneralpurposeuse.TheSPIAppisa
commandlineinterfaceforcontrollingSPIdevices.TheGPIOAppprovidesacommandlineinterface
forcontrollingsomeoftheunderlyinghardwareoftheATmega32U2usedintheZeptoProg.Uses
includemeasuringfrequencies,outputtingsquarewaves,PWM,andgeneralpurposeI/O.
4toolsin1
June11,2011
http://www.mattairtech.com/
ZeptoProg
June11,2011
UserGuide
http://www.mattairtech.com/
ZeptoProg
UserGuide
Features
AVRISPmkIIcompatibleAVRProgrammer
SupportsallAVRswithISP,PDI,orTPIprogramminginterface
IncludesmegaAVR,tinyAVR,XMEGA,andUSB,PWM,andCANAVRs
StandardpinoutforISPandPDI(6pinseach)
CanhavebothISPandserialcablesconnected
Easyswitchingbetweenprogrammingandserialbridge(usefulfordebugging)
OptionalrecoveryclockforISP
Upto8MHzprogrammingspeed(4MHzislimitoncurrentAVRs)
Programflash,EEPROM,fuses,lockbits,andmore
WorkswithAVRStudio4and5,AVRDUDE,Codevision,andBASCOM2.0.6
SerialBridge
Upto2MHzbaudrate
Synchronousorasynchronousoperation
Optionalflowcontrolvia_CTSpin
SPIApp
Upto8MHzclock
ZeptoProgismaster,Modes03,MSBorLSB
4opendrainchipselectoutputs
Commandlineinterfaceviaterminalemulator
GPIOApp
Upto
7TTLinputs
9outputs(5levelshifted)
2PWMoutputswithseparatedutycycles
1frequencyoutput
1frequencymeasurementinput
Commandlineinterfaceviaterminalemulator
Upgradeablefirmware
USBbuspowered
2buttonsforcontrol
2LEDsforstatusindication
Targetboardvoltagesupportof2Vto5Vvialevelshiftedoutputsontwomainheaders
ReversepolarityprotectiononVtgtandGNDpins(versionwithcaseonly)
Overcurrentprotectiononlevelshiftedoutputsviaseriesresistors
EnclosedinasmallblackplasticUSBdonglecase(versionwithcaseonly)
Measures6.4cm(5.1cmnotincludingUSBconnector)x2.5cmx1.4cm
CompatiblewithWindowsXP/Vista/7andLinux
UsesLUFAUSBlibraryandAVRISPmkIIclonebyDeanCamera
(http://www.fourwalledcubicle.com/)
June11,2011
http://www.mattairtech.com/
ZeptoProg
UserGuide
About
ContactInformation
Justin Mattair
MattairTech LLC
PO Box 1079
Heppner, OR 97836 USA
541-626-1531
[email protected]
http://www.mattairtech.com/
SupportInformation
TheZeptoProgfirmwareiscurrentlystillunderdevelopment.Newfeaturesareplanned(ie:a
simplelogicanalyzer).PleasechecktheMattairTechwebsite(http://www.MattairTech.com/)for
updates.Emailmeifyouhaveanyfeaturerequests,suggestions,orifyouhavefoundabug.Ifyou
needsupport,pleasecontactme(emailisbest).Youcanalsofindsupportinformationatthe
MattairTechwebsite.SupportforAVRsingeneralcanbefoundatAVRfreaks
(http://www.avrfreaks.net/).There,Imonitortheforumssectionastheuserphysicist.
Precautions
CAUTION
The ZeptoProg should be powered before connecting the target
board. DO NOT connect Vtgt and Gnd in reverse polarity (Version
with case has reverse polarity protection, version without case
does not have reverse polarity protection).
CAUTION
The ZeptoProg contains static sensitive components. While the
case provides some protection from the environment, the pins are
still exposed. Use the usual ESD procedures when handling.
CAUTION
Improper fuse settings may result in an unusable AVR. Be certain
that you know the effects of changing the fuses, that you
understand the convention used for describing the state of the
fuses (programmed = 0), and that you are using an appropriate
programming speed before attempting to change fuse settings.
Specifically, don't set the RSTDSBL fuse.
June11,2011
http://www.mattairtech.com/
ZeptoProg
UserGuide
WindowsInstallation
TheZeptoProgissupportedunderWindowsXP,Vista(32and64bit),andWindows7(32and
64bit).ThereislimitedsupportforWindows2000.TheZeptoProgappearsasthreedifferentdevices
tothePCdependingonwhichmodeisselectedbythebuttons.ThesedevicesaretheAVR
programmer(emulatesAVRISPmkII),theDFUbootloaderforfirmwareupdates,andtheUSBCDC
device(VirtualCOMport)whichisusedforallothermodes.Assuch,threedriversarerequired.Two
ofthesedriversareincludedwithsoftwareavailableontheAtmelwebsite.Thethirddriverisincluded
withWindows,butrequiresan.inffileavailableontheMattairTechwebsite.
BeforepluggingintheZeptoProgforthefirsttime,thelatestsoftwareanddriversmustbe
downloaded.Itisimportanttousethelatestversions,especiallyifinstallingonWindowsVistaor
Windows7.Thefollowingtableliststheminimumversionsoftherequiredsoftware.Ifthesoftware
providesadriver,isislistedaswell.
RequiredDownloads
Software
Version
Driver
URL
WinAVR
20100110
N/A
http://sourceforge.net/projects/winavr/files/
WinAVR/20100110/
AVRStudio
4.18SP3
AVRISPmkII
http://www.atmel.com/dyn/products/tools_c
ard.asp?tool_id=2725
FLIP
3.4.2
DFUBootloader
http://www.atmel.com/dyn/products/tool
s_card.asp?tool_id=3886
latest
http://www.avrfreaks.net/index.php?mo
dule=Freaks%20Academy&func=viewIt
DFUBootloader
em&item_type=project&item_id=2196
DFUDriver
(IfFLIPdriverfails)
ZeptoProgDriver
latest
CDCdriver
http://www.mattairtech.com/
ZeptoProgFirmware
latest
N/A
http://www.mattairtech.com/
WinAVR/AVRDUDE
WinAVRcontainstheGNUGCCcompilerforCandC++,compilertools,andlibraries
(includingAVRLibc).ItalsoincludesAVRDUDEforWindows,whichisacommandlinetoolfor
transferringfirmwaretoAVRmicrocontrollers.AgraphicaltoolisincludedwithAVRStudio.Download
WinAVRfromhttp://sourceforge.net/projects/winavr/files/WinAVR/20100110/andinstallitfirst.Ifyou
wishtouseAVRDUDE,youmayneedtodownloadandinstallanupdatetolibusbwin32availableat
http://sourceforge.net/projects/libusbwin32/files/libusbwin32releases/.Choosethelibusbwin32
develfilterx.x.x.x.exefile.DothisonlyafterinstallingAVRStudioandonlyifAVRDUDEthendoesnot
work.
June11,2011
http://www.mattairtech.com/
ZeptoProg
UserGuide
AVRStudio/AVRISPmkIIdriver
AVRStudioisanIDEthatincludesanassembler,debugger,simulator,andanAVRchip
programmingtool.ItworkswithGCCthroughacompilerplugin.Twofilesmustbedownloaded,the
mainprogramandaservicepack.First,downloadAVRStudio4.18from
http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2725.ThendownloadSP3fromthesame
pageandbegininstallation.BesuretoinstalltheJungodriverswhenaskedduringbothsetup
procedures.TheyincludetheAVRISPmkIIdriverneededbytheZeptoProgAVRprogrammer.
NowtheAVRISPmkIIdrivercanbeinstalled.PressbuttonA(left)andholdwhilepluggingin
theZeptoProg.ThiswillruntheAVRISPmkIIcompatibleAVRprogrammer.LEDAshouldbelitand
LEDBshouldbesmoothlyflashingonandoff.WindowswillthenpromptyoufortheZeptoProgAVR
Programmerdriver.Bydefault,thisislocatedintheProgramFiles/Atmel/AVRJungoUSBdirectory.
PointtheinstallertotheappropriatesubdirectoryforyourPCarchitecture(usb32orusb64)andinstall
thedriver.DonotusethedriverintheAVRTools/usbdirectory.Oncethedriverisloaded,thedevice
willappearastheAVRISPmkIIdeviceunderJungointhedevicemanager.
June11,2011
http://www.mattairtech.com/
ZeptoProg
UserGuide
FLIP/DFUBootloaderDriver
FLIPisagraphicalutilityusedtoloadfirmwareupdatesontotheZeptoProg.Updateswillbe
madeavailableattheMattairTechwebsite.FLIPincludestheDFUbootloaderdriver.DownloadFLIP
3.4.2orhigherfromhttp://www.atmel.com/dyn/products/tools_card.asp?tool_id=3886andinstall.If
requiredtoinstallsigneddriversandtheAtmeldriversdonotwork,downloadthesigneddriversat
http://www.avrfreaks.net/index.php?module=Freaks%20Academy&func=viewItem&item_type=project&
item_id=2196andinstall.
OnceFLIPisinstalled,theDFUbootloaderdriverscanbeloaded.Pressandholdbothbuttons
whilepluggingintheZeptoProg.ThiswillentertheDFUbootloader.LEDAshouldbeoffandLEDB
shouldbeon.WindowswillthenpromptyoufortheATmega32U2driver.Bydefault,thisislocatedin
theProgramFiles/Atmel/Flip3.4.2/usbdirectory.Pointtheinstallertothatdirectoryandinstall.Once
thedriverisloaded,thedevicewillappearastheATmega32U2deviceunderAtmelUSBDevicesin
thedevicemanager.
June11,2011
10
http://www.mattairtech.com/
ZeptoProg
UserGuide
ZeptoProgDriver/SerialConfiguration
Finally,wewillinstalltheZeptoProgCDCdriver,whichisusedbyConfigurationModeand
ApplicationMode.ThisdriverallowstheboardtoappearasaCOMport.Thedriveritselfisincluded
withWindows,butan.inffileisneededtoconfigureit.Downloadthe.inffilefrom
http://www.mattairtech.com/.Now,plugintheZeptoProgwithoutholdingdowneitherbutton.Thiswill
runApplicationMode(usingtheGPIOAppbydefault).BothLEDsshouldbelit.Windowswillthen
promptyoufortheZeptoProgCDCdriver.Pointtheinstallertothedirectorywhereyoudownloaded
thedriverandinstall.Ignoreanywarnings.Oncethedriverisloaded,thedevicewillappearasthe
ZeptoProgCDCdeviceusingaCOMportinthedevicemanager.
June11,2011
11
http://www.mattairtech.com/
ZeptoProg
UserGuide
Ifyouwish,doubleclickontheZeptoProgCDCdeviceentryinthedevicemanagerto
configurethedriver.ClickonthePortSettingstab.Youcanleavethesettingsatthedefaultvalues.
NotethatweareusingavirtualCOMportandtheZeptoProgignoresthesesettings.Thebaudrate
willalwaysbeasfastaspossible.ClickonAdvanced.HereyoucanadjusttheFIFObuffersizes.If
youexperienceanybufferingproblems,forexample,adelayedresponsetouserinputinthe
configuration,thenchangebothbuffersizesto1.Youmaywishtodothisnowanywayevenifyoudo
notcurrentlyhaveanytrouble.
June11,2011
12
http://www.mattairtech.com/
ZeptoProg
UserGuide
TerminalEmulator
Nowwearereadytoconfiguretheterminalemulator.WindowsXPincludesHyperTerminal,
whichhasbeentestedwiththeZeptoProgandwillbedocumentedhere.Thereareseveralother
terminalemulatorsavailablefreelyontheInternet.Ifyouwishtouseanyofthem,itshouldbeno
troubletoadapttheinstructionspresentedhere.PlugintheZeptoProgwhileholdingButtonBdown.
ThiswillrunconfigurationmodewhichusestheCDCdriver.LEDAshouldbeonandLEDBshouldbe
off.
Next,startHyperTerminal.Createanewconnection.Youwillrefertothisconnectionagain,so
giveitanappropriatename(afteritisconfigured,youcancopyittoyourdesktop).Selectthe
ZeptoProgCOMport(ie:COM4)andcontinue.Youcanconfiguretheconnectionasbefore,butthis
shouldnotbenecessary,astheyshouldbeignored.
June11,2011
13
http://www.mattairtech.com/
ZeptoProg
UserGuide
Afterconnecting,youmayseegarbageontheterminalscreen.Ifthisisthecase,clickonthe
configurationiconandchangetheemulationtoANSI(orANSIW).Theconfigurationmoderequiresan
ANSIterminaltoallowdrawingofthemenusystem.Normally,whenfirstenteringamodethatusesthe
CDCdriver,amessagethatreadsPressanyKeyisprintedperiodically.Ifyoudonotseethis
message,thentoomuchtimehaspassedbetweenfirstprintingthemessageandtheuserconnecting
theterminalemulator.Inthiscase,thescreenmaybeblank.Justpressanykeytocontinue.Notethat
itmaynotbepossibletoswitchbetweenmodesusingthebuttonsuntilakeyispressed.Alsonotethat
whenTerminalModeisdisabled,thePressanyKeymessagedoesnotappear,andnokeyneedsto
bepressedfortheselectedapplicationtobeready.
ItisimportanttoalwaysclickthedisconnecticonbeforeswitchingtotheAVRProgrammerfrom
configurationmodeorapplicationmode.Thenclicktheconnecticonacouplesecondsafterreturning.
ThisisrequiredbecausechangingtotheAVRISPmkIIdriverunloadstheCDCdriver,thenloadsthe
AVRISPmkIIdriver.InorderfortheterminaltousethesameCOMportasbefore,itmustbe
disconnectedwhenreturningtotheCDCdriversothatitdoesnotassignanewCOMport.Afuture
firmwarereleasemayincludetheabilitytohavebothdriversloadedsimultaneously.
LinuxInstallation
Linuxissupportedaswell.Youmustdownloadandbuildthetoolchainfromthelatestscript
availableatAVRFreaksontheAVRGCCForum(ScriptforbuildingAVRGCCstickyat
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=42631).Allfirmwarewritten
fortheZeptoProgisdevelopedunderLinuxusingthistoolchain.
Drivers
TODO(driversshouldalreadybeinstalled)
GCCToolchain
TODO(seeopeningparagraph)
AVRDUDE
TODO(ie:avrdudepx128a1cavrisp2PusbUflash:w:"myfirmware.hex")
dfuprogrammer
TODO(mustuseversion0.5.2(currentlyavailableviaSVNonly)orhigher)
TerminalEmulator
TODO(canuseminicom,configport(ie:/dev/tty/ACM0),saveconfig,runwithminicomo)
June11,2011
14
http://www.mattairtech.com/
ZeptoProg
UserGuide
ZeptoProgHardware
Layout/HeaderPins
Header B
6
GND
5 / 11
XCK / out
1/4
MISO / in
2
Vtgt
4 / 10
_CTS / in
3/9
TX / out
3/5
SCLK / out
4/6
MOSI / out
2
Vtgt
1/8
RX / data / in
5/7
RST / out
6
GND
June11,2011
15
http://www.mattairtech.com/
ZeptoProg
UserGuide
PinDescriptions
Pin
Description
GPIO0
GPIOApp:TTLinput,output(NOTlevelshifted)
SPIApp:ChipSelect0(opendrain,activelow)
GPIO1
GPIOApp:TTLinput,output,PWM,frequencyoutput(NOTlevelshifted)
SPIApp:ChipSelect1(opendrain,activelow)
GPIO2
GPIOApp:TTLinput,output,PWM,frequencyoutput(NOTlevelshifted)
SPIApp:ChipSelect2(opendrain,activelow)
GPIO3
GPIOApp:TTLinput,output(NOTlevelshifted),frequencyinput
SPIApp:ChipSelect3(opendrain,activelow)
MISO/GPIO4
GPIOApp:TTLinput(highimpedance)
SPIApp:MISO
AVRProgrammer:MISO(ISPmode)
SCLK/GPIO5
GPIOApp:output(levelshifted,shortcircuitprotected)
SPIApp:SCLK
AVRProgrammer:SCLK(ISPmode)
MOSI/GPIO6
GPIOApp:output(levelshifted,shortcircuitprotected)
SPIApp:MOSI
AVRProgrammer:MOSI(ISPmode)
RST/GPIO7
GPIOApp:output(levelshifted,shortcircuitprotected)
SPIApp:unused(alwayshigh)
AVRProgrammer:Resetoutput(ISP/TPImode)
RX/data/GPIO8
GPIOApp:TTLinput(highimpedance)
SerialApp:RX
AVRProgrammer:data(PDI/TPImode,bidirectional)
Notethatinthismode,theAVRTXandRX
pinsaretiedtogetherandroutedtothispin.
TX/GPIO9
GPIOApp:output(levelshifted,shortcircuitprotected)
SerialApp:TX
AVRProgrammer:unused(highimpedance)
_CTS/GPIO10
GPIOApp:TTLinput(highimpedance)
SerialApp:_CTS(activelow,disabledbydefault)
AVRProgrammer:unused(highimpedance)
XCK/GPIO11
GPIOApp:output(levelshifted,shortcircuitprotected)
SerialApp:clock(synchronousmode)
AVRProgrammer:clock(PDI/TPImode),
recoveryclock(ISPmode,disabledbydefault)
Vtgt
2V5VVoltageinputfromtarget.Thisisusedtosetthelevelshifter
outputvoltage.Reversepolarityprotected(versionwithcaseonly).
GND
Ground
June11,2011
16
http://www.mattairtech.com/
ZeptoProg
UserGuide
Buttons
Therearefourmodesofoperationwhichareselectedusingthebuttons.Themodecanbe
selectedwhenpluggingintheZeptoProgbyholdingdowntheappropriatebuttons(ifany).Ifnobutton
ishelddown,ApplicationModewillrun.Mostmodescanbechangedduringruntimeaswell,except
theDFUBootloader,whichcanonlybeaccessedduringpowerup.PressingButtonAalsoservesasa
reset,viatheAVRwatchdog,inallmodesexcepttheAVRProgrammer.Thefollowingtableliststhe
buttonfunctionalityatpowerupandruntime.
ButtonFunctionalityDuringPowerup
Button A
Button B
Mode
Pressed
NotPressed
AVRProgrammer
NotPressed
Pressed
ConfigurationMode
NotPressed
NotPressed
ApplicationMode
Pressed
Pressed
DFUBootloader
ButtonFunctionalityDuringRuntime
Button A Action
Button B Action
Current Mode
SwitchtoAppMode
SwitchtoConfiguration
AVRProgrammer
Reset,runprogrammer
SwitchtoAppMode
ConfigurationMode
Reset,runprogrammer SwitchtoConfiguration
ApplicationMode
Reset,runprogrammer
DFUBootloader
N/A
Ingeneral,duringruntime,pressingButtonAswitchesbetweentheAVRProgrammerand
ApplicationMode.PressingButtonBswitchesbetweenApplicationModeandConfigurationMode.
Thisbuttonconfigurationallowstheusertoswitchbetweenanapplicationandtheconfigurationforthe
applicationwithouthavingtodisconnecttheterminalemulator.Forexample,iftheSerialAppis
configuredtoruninApplicationMode,theusercanexperimentwithdifferentbaudratesettingsquickly
byswitchingbetweenConfigurationModeandApplicationMode.TheSerialAppcouldthenbeused
forprintf()debuggingthesamewayanormalserialconnectioncan.TheusercoulduseButtonAto
switchbetweentheAVRProgrammerforchipprogramming,andtheSerialAppfordebuggingoutput.
June11,2011
17
http://www.mattairtech.com/
ZeptoProg
UserGuide
LEDs
TherearetwogreenLEDsthatareusedtoindicateUSBstatus,themodeofoperation,
communicationactivity,programmerstatus,andmore.ThefollowingtablelistsLEDfunctionalityin
eachmode.WhenanLEDhasadualrole,theonelistedontheleftisthenormal/defaultstate.
LEDFunctionality
Mode / App
LED A
LED B
AVRProgrammer
USBStatus/
ProgrammerActivity
PWMflashing
Slow:Targetboardabsentor
Vtgttoolow
Fast:Targetboardconnected
ConfigurationMode
USBStatus
Off
SerialApp
USBStatus/RXActivity
On/TXActivity
SPIApp
USBStatus
On/SPIActivity
GPIOApp
USBStatus
On
DFUBootloader
Off
On
June11,2011
18
http://www.mattairtech.com/
ZeptoProg
UserGuide
Configuration
TheZeptoProgAVRProgrammerandApplicationModecanbeconfiguredbyentering
ConfigurationMode.ThisconfigurationisstoredinnonvolatileEEPROMmemory.Configuration
moderequiresanANSIterminalemulator.Configurationoptionsarehighlightedbyusingtheupand
downarrowkeys,andselectedusingtheenterkey.Somedialogsareforenteringnumbersin
hexadecimal.Here,theleftarrowkey,rightarrowkey,andbackspacecanbeused.Thefollowinglists
thestructureofthemenusystem:
SelectApp
SerialApp
SPIApp
GPIOApp
TerminalMode
Disabled
(NonInteractiveMode,intendedforusebyusercode,scripts)
Enabled
(TerminalMode,intendedforterminalemulators)
ConfigSerial
(seeSPIAppsectionforconfigurationoptions)
ConfigAVRISPmkII
(seeSerialAppsectionforconfigurationoptions)
ConfigSPI
(selectbetweenTerminalModeandNonInteractiveMode)
(selectwhichapplicationwillrunwheninApplicationMode)
(seeAVRProgrammersectionforconfigurationoptions)
Credits
(displayslistoffirmwareauthors)
WhenenteringApplicationMode,theAppselectedunderSelectAppwillrun.Toswitchto
anotherApp,theusermustswitchtoApplicationMode,changetheselectedApp,thenswitchbackto
ApplicationMode.AlloutputsaretristatedwheninConfigurationMode,andnoinputsareactive.This
isagoodtimetomakeconnectionchanges,ifnecessary.
TerminalModeallowstheZeptoProgtouseaterminalemulator.ThismodeaffectstheGPIO
AppandSPIApp.Ingeneral,enablingTerminalModecausesaPressanykeyprompttoappear
uponenteringanymodethatusesthevirtualCOMport(thisisdoneonlyonceperreset),causesa
prompttoappear,echoessentcharacters,outputscarriagereturnandnewlinetotheterminalupon
pressingenter,andoutputserrormessagesastextstringsratherthansinglebytecodes.Additionally,
thebehavioroftheSPIcommandschanges.NonInteractiveModeiswhenTerminalModeissetto
disabled.ThismodeisusefultointerfacewithusercodeonthePC,likeascriptorprogram.
June11,2011
19
http://www.mattairtech.com/
ZeptoProg
UserGuide
AVRProgrammer
TheZeptoProgAVRProgrammerisbasedontheAVRISPmkIIcompatibleprogrammerwritten
byDeanCamera(http://www.fourwalledcubicle.com/).ItsupportsprogrammingofallAtmelAVR
microcontrollerswithanISP,PDI,orTPIprogramminginterface.TheseincludethemegaAVRseries
(ISP),thetinyAVRseries(ISP,TPI),theXMEGAseries(PDI),theUSBAVRs(ISP),andthelistedCAN
andPWMAVRs(seeAppendixBfordevicelisting).TheZeptoProgusesthestandardheaderpinouts
forbothISPandPDI.TPIdoesnotusethestandardpinout,however,singlepinjumpercablescanbe
used.Atthetimeofthiswriting,only6pindevicesuseTPI.
Programmingspeedsupto8MHzaresupportedinISPmode.However,currentAVRsrequirea
programmingspeedlessthanofthetargetclockspeed.For20MHzAVRs,thisis4MHz.For
16MHz,2MHzisthelimit.Itisnotrecommendedtooperateatexactlyofthetargetfrequency,
especiallywhenprogrammingfuses,asthiscancausethemtobecomeincorrectlysetandpossibly
rendertheAVRuseless(unlessparallelprogrammingisavailable).NotethatmanyAVRscomefrom
thefactorywiththeclocksourcesettotheinternal8MHzoscillatorandwiththeCKDIV8fuse
programmed,resultinginaclockspeedof1MHz.Inthesecases,theISPprogrammingspeedshould
besetto125KHzorlessuntilCKDIV8isunprogrammedandpowercycled.
ForISPmode,a1MHzrecoveryclockcanbeenabled.Thisclockcanbeconnectedtothe
targetclockinput.Thisisuseful,forexample,toallowresettingoffusesthatweremisconfiguredto
useanexternalclockwhenintendingtouseacrystalorinternaloscillator.Thisrecoveryclockshould
onlybeusedwithanISPprogrammingspeedof125KHz.
TheZeptoProgsupportstargetdevicesoperatingat2Vto5V.OutputsfromtheZeptoProgare
levelshifteddowntothetargetvoltage.ThetargetdevicesuppliesthisvoltageviatheVtgtinput.This
inputisreversepolarityprotectedbyaFETtoensurealowvoltagedrop.Theoutputshaveseries
resistorsthatlimitcurrenttoaround25mA.
Configuration
PCProgram
(UnderWindows,thismustbesettotheprogramusedwiththeAVRProgrammer)
AVRStudio
AVRDUDE
RecoveryClock
Disabled
Enabled
(Ifenabled,inISPmodea1MHzclockwillbeoutputonXCKpinofheaderA)
ConnectingTargetBoard
AlwaysensurethattheZeptoProgispoweredbeforeconnectingthetargetboard.Inallthree
modes,theVtgtpinisusedasaninputtotheZeptoProgthatdeterminestheoutputhighvoltage.This
mustbesuppliedbythetargetboard.Itispossibletooutput5VfromUSBtothetargetboard,thus
poweringthetargetboard.Caremustbetakenwhendoingthis.ConsultAppendixAformore
June11,2011
20
http://www.mattairtech.com/
ZeptoProg
UserGuide
information.
ISPmodeusesthestandardpinout,andisavailableonheaderB.Ifenabled,a1MHzrecovery
clockwillbeoutputontheXCKpinofheaderA.
PDImodealsousesthestandardpinout,andisavailableonheaderA.DuringPDI
programming,theZeptoProgUSARTTXandRXlinesareinternallytiedtogetherand
connectedtotheRX/datapin.Inthisconfiguration,thepiniscalleddataandisbidirectional.
TheTXpinwillthenbetristated.Since_CTSisunusedbytheprogrammer,itisalsotristated.
TPIusesanonstandardpinout.TPIusesthesamesignalsasPDIbutwiththeadditionof
Reset.TheResetoutputisavailablefromRSTonheaderB.DataandXCKaretakenfrom
headerA.DuringTPIprogramming,theZeptoProgUSARTTXandRXlinesareinternallytied
togetherandconnectedtotheRX/datapin.Inthisconfiguration,thepiniscalleddataandis
bidirectional.TheTXpinwillthenbetristated.Since_CTSisunusedbytheprogrammer,itis
alsotristated.
UsingAVRStudio
WhenAVRStudioisrun,itwillaskyouifyouwanttoopenorcreateanewproject.Fornow,
youcanstartatestproject.MakeitaGCCproject.ClickFinish.Youmayalsowishtochangethe
projectoptions.Clickthegearicon,enterthetargetclockspeed,andselectyourtargetdevice.Now
clickonthechipiconthatreads'Con'.SelecttheAVRISPmkIIastheprogrammerandUSBasthe
connectionmethod,thenclickConnect.IfadialogpopsupaskingwhichAVRISPmkIIversionyouare
using,select0000A0012825.
June11,2011
21
http://www.mattairtech.com/
ZeptoProg
UserGuide
Onceconnected,atabbedwindowwillappear.Thisistheinterfacetoprogrammingthetarget
device.Here,youcanloadfirmware,read/writetheEEPROM,modifyfuses,changelockbitsettings,
andmore.Clickonthefirsttab.Makesurethecorrectdeviceisselected,thenclickReadSignature.It
shouldmatchthedeviceifalliswell.Itisrecommendedtoalwaysperformthisstepfirsttoverifythe
connection.ThefollowingscreenshotsshowtheZeptoProginPDImodeinterfacingwithan
ATxmega128A1.
June11,2011
22
http://www.mattairtech.com/
ZeptoProg
UserGuide
Next,clickontheProgramtab.IntheFlashsection,ahexfilecanprogrammedintothetarget's
flashmemory.Loadyourhexfile,thenclickProgram.Youwillneedtoerasethetargetfirstifyoudo
nothaveErasedevicebeforeflashprogrammingchecked.Youshouldalsoverifythedeviceafter
programming.
June11,2011
23
http://www.mattairtech.com/
ZeptoProg
UserGuide
Next,clickontheFusestab.Itisbesttoleavethefusesettingsaloneuntilyouunderstand
whattheydo.Inparticular,ifusingISP,donotprogramRSTDISBLorunprogramSPIEN,asthiswill
lockyououtofthetargetchip.DonotsettheBOD(Brownoutdetection)voltagetoalevelabovethe
targetchipvoltage,asthiswillcausethetargettobeheldperpetuallyinreset.Youmustalsobe
carefulwiththeclocksettingsaswell.Ifyouselectthewrongclocksource,thenyourtargetchipwill
notoperateiftheconfiguredclocksourceisnotpresent.However,theZeptoProgprovidesarecovery
clockwhichcanbeusedtorecoverfromthissituation.
June11,2011
24
http://www.mattairtech.com/
ZeptoProg
UserGuide
Nowyoumaywishtolookattheothertabs.NotethatontheHWSettingstab,thereported
voltagewillalwaysbe5V,regardlessoftheactualvoltagepresentonVtgt.TheFirmwareupgrade
featureonthesametabshouldnotbeused.ThisisalsotruefortheAVRISPmkIIupgradefeaturein
theAVRStudiotoolsmenu,oranyupgradepopupwindows.TheZeptoProgAVRProgrammerisnot
anactualAVRISPmkII,itjustemulatesone,soyoushouldnotattempttoupdatetheZeptoProg
firmwareusingAVRStudio.AnyfirmwareupdateswillbepostedtothewebsiteandloadedusingFLIP
ordfuprogrammer.
UsingAVRDUDE
TODO(ie:avrdudepx128a1cavrisp2PusbUflash:w:"myfirmware.hex")
June11,2011
25
http://www.mattairtech.com/
ZeptoProg
UserGuide
GPIOApp
TheGPIOAppisacommandlineinterfacetoseveralfeaturesoftheAVRmicrocontrollerused
intheZeptoProg.Youcanuseittooutputsquarewavesatdifferentfrequencies,outputPWM
waveforms,measurefrequencies,readinputsandcontroloutputs.ThisAppwillbeupdatedwithnew
featuresinthefuture.ThefollowingtableliststhecapabilitiesofeachpinusingtheGPIOApp.
PinCapabilities
Pin
Capabilities
Level Shifted /
Current Limited
Input,Output
No
Input,Output,PWM,FrequencyOut
No
Input,Output,PWM,FrequencyOut
No
Input,Output,FrequencyIn
No
Input
NA
Output
Yes
Output
Yes
Output
Yes
Input
NA
Output
Yes
10
Input
NA
11
Output
Yes
GPIOAppConfiguration
TheGPIOAppisselectedasthecurrentapplicationbyswitchingtoConfigurationMode
(ButtonB)andselectingGPIOAppunderSelectApp(seeConfigurationsection).Theonly
configurationthataffectstheGPIOAppistheTerminalModesetting.WhenTerminalModeis
enabled(thedefaultsetting),theAppwilloutputaprompt,echosentcharacters,sendcarriagereturn
andnewlinecharacterswhentheuserpressesEnter,andprintresponsesastextstrings(ie:SYNTAX
ERROR).Whenterminalmodeisdisabled,nopromptisprinted,charactersarenotechoed,only
newlinesaresent,andresponsecodesaresinglebytes(ie:0x01).Thefollowingtableliststhe
responsecodesforbothmodes.
June11,2011
26
http://www.mattairtech.com/
ZeptoProg
UserGuide
ResponseCodesforGPIOApp
Terminal Mode
Non-Interactive Mode
OK
0x00
SYNTAXERROR
0x01
INVALIDPIN
0x02
INVALIDVALUE
0x03
PININUSE
0x04
INVALIDTIMERCONFIG
0x05
OUTOFMEMORY
0x06
CAPTUREOVERFLOW
0x07
CAPTUREOUTOFRANGE
0x08
CANNOTUNCONFIG
0x09
GPIOPinConnections
AlwaysensurethattheZeptoProgispoweredbeforeconnectingthetargetboard.Inallmodes,
GndandVtgtmustbeconnectedtothetargetboard.Whilepins03havemultiplefunctions,thelevel
shiftedpinsoftheheadersarefixedtofunctionaseitherinputoroutput.
PinConfiguration
Bydefault,eachpinisunconfigured.Inthisstate,thepinistristated.Eachpinmustbe
configuredbeforeuse.Ingeneral,theconfigcommandisusedtoassociateapinwithavalidfunction
(ie:input).Inadditiontosettingthefunctionofapin,theconfigcommandsetsconfigurationforthe
selectedfunction.Forexample,apullupcanbeenabledforpinsconfiguredasaninput.Some
functionsrequirethetimertobeconfiguredfirst(ie:PWM).Inthiscase,theconfigtimercommandis
usedfirst,thenthepinconfigurationcommand.Thepinortimerconfigurationcanbechangedby
usingtheconfigcommandagainwiththenewconfiguration.Forconfigargumentsthatareoptional
andnotspecifiedonthecommandline,defaultvaluesareloadeduponinitialconfiguration,butnot
uponanyfuturereconfigurations.Theexceptiontothisiswithargumentsthathaveonlyoneoption
(ie:pullupargumentoftheconfigincommand).Inthiscase,specifyingitwillenablethefeature,
whileomittingitdisablesthefeature(insteadofleavingitunchanged).
config{pin}in|out|pwm|fi|fo(functionspecificarguments)
returns:
June11,2011
(variesbyfunction)
27
http://www.mattairtech.com/
ZeptoProg
example:
UserGuide
config3inpullup
{pin}:Requiredargumentindicatingthepinnumbertoassign.Canbe011.
in|out|pwm|fi|fo:Requiredargumentspecifyingthefunctionthepinistobeassignedto.instandsfor
input,outstandsforoutput,pwmstandsforpulsewidthmodulation,fistandsforfrequencyinput,and
fostandsforfrequencyoutput.
(functionspecificarguments):Argumentsspecifictoeachfunction,whichmayincluderequired
arguments,shouldbeplacedhere.
Ifapinmustbechangedtoadifferentfunction(ie:frominputtooutput),thenitmustbe
disassociatedwiththecurrentfunctionbyusingtheunconfigcommandfirst.Likewise,ifthetimeris
switchedtoadifferentfunction(ie:PWMtofrequencyoutput)andapiniscurrentlyassociatedwiththe
function,thenthepin(s)mustbeunconfiguredfirst.
unconfig{pin}
returns:
OK|SYNTAXERROR|INVALIDPIN|CANNOTUNCONFIG
example:
unconfig3
{pin}:Requiredargumentindicatingthepinnumbertounassign.Canbe011.
TimerConfiguration
ThetimermustbeconfiguredforthePWM,frequencyoutput,andfrequencyinputfunctions.
Theconfigtimercommandconfiguresthetimerforthespecifiedfunction.Theprescalersetting(ie:
div1)affectsallthreefunctions,whiletherestofthesettingsareusedonlybythePWMfunction.
configtimer[off|pwm|fo|fi][div1|div8|div64|div256|div1024][fast|phase|freq][top{value(16b)}]
returns:
OK|SYNTAXERROR|INVALIDVALUE|PININUSE
example:
configtimerpwmfasttop0x7fff
[off|pwm|fo|fi]:Optionalargumentthatspecifiesthefunctionthetimerwillbeusedfor(defaultoff).fo
standsforfrequencyoutputandfiforfrequencyinput.
[fast|phase|freq]:OptionalargumentthatspecifieswhatmodethePWMfunctionwillrunin(default
fast).ThesecorrespondtothePWMmodesoftheunderlyingAVRmicrocontroller.Pleaseconsultthe
Atmega32U2datasheetformoreinformation.phasestandsforphasecorrectandfreqstandsfor
phaseandfrequencycorrect.ThissettingisignoredwhenselectinganonPWMfunction.
June11,2011
28
http://www.mattairtech.com/
ZeptoProg
UserGuide
[div1|div8|div64|div256|div1024]:Optionalargumentthatspecifiesthetimerprescalersetting
(defaultdiv1).Thisisthedividerofthe16MHzclockfrequency.Thetimerwilltickatthisdivided
frequency.PleaseconsulttheAtmega32U2datasheetformoreinformation.
[top{value(16b)}]:Optionalargumentthatspecifiesthe16bittopvalueofthetimer(default=0xffff)
usedinPWMmodes.Thisisthevaluethetimerwillcountuptobeforeresettingbackto0(or
beginningdowncountingincertainPWMmodes).Thissettingcombinedwiththeprescalersetting
abovesetsthePWMfrequency.TopcannotbebelowthePWMdutycycle.
Input
TheconfigincommandconfiguresthepintobeusedasaTTLcompatibleinput.Apullup
resistorcanoptionallybeenabled.Theincommandcanthenbeusedtoreadthevalueoftheinput(h
orl).Voltagesaslowas2Vwillregisterasahigh.
config{pin}in[pullup]
returns:
OK|SYNTAXERROR|PININUSE|INVALIDPIN|OUTOFMEMORY
example:
config1inpullup
{pin}:Requiredargumentindicatingthepinnumbertoassign.
[pullup]:Optionalargumentthatenablesthepullupresistor(defaultdisabled).
in{pin}
returns:
IN{pin}h|l
or
INVALIDPIN
example:
in1
IN1h
{pin}:Requiredargumentindicatingthepinnumbertoread.
Output
Theconfigoutcommandconfiguresthepintoserveasanoutputthatcandrivehighanddrive
low.Theinitialstate(horl)canoptionallybespecified.Theoutcommandcanthenbeusedtocontrol
theoutput.
config{pin}out[h|l]
June11,2011
29
http://www.mattairtech.com/
ZeptoProg
UserGuide
returns:
OK|SYNTAXERROR|PININUSE|INVALIDPIN|OUTOFMEMORY
example:
config1out
{pin}:Requiredargumentindicatingthepinnumbertoassign.
[h|l]:Optionalargumentspecifyingtheinitialstate(defaulthigh).
out{pin}h|l
returns:
OK|SYNTAXERROR|INVALIDPIN
example:
out1h
{pin}:Requiredargumentindicatingthepinnumbertocontrol.
h|l:Requiredargumentspecifyingtheoutputstate.
PWM
TheconfigpwmcommandconfiguresthespecifiedpintooutputaPWMsignal.Themeaning
ofdutycycle(normalorinvert)canoptionallybespecified.Whennormal,theoutputwillnormallybe
low,withthehighpulsetimecorrespondingtothedutycycle.Wheninverted,theoutputwillnormally
behigh,withthelowpulsetimecorrespondingtothedutycycle.Whenconfigured,thepwmcommand
canbeusedtochangethedutycycle.Notethattwopins(1and2)canbeusedforPWM
simultaneouslywithtwodifferentdutycycles,buttheymustsharethesamePWMfrequency.
ThePWMfrequencyisconfiguredduringtimerconfiguration.Additionally,themodeof
operation(fastPWM,phasecorrectPWM,andphaseandfrequencycorrectPWM)isspecifiedduring
timerconfiguration(seeabove).ThefollowingequationscanbeusedtodeterminethePWM
frequency:
F PWM=
F PWM =
16MHz
(fastPWM)
prescaler1TOP
16MHz
(phase/freqPWM)
2prescalerTOP
Theresolutioninbitscanbefoundby:
RFPWM =
June11,2011
logTOP1
log2
30
http://www.mattairtech.com/
ZeptoProg
UserGuide
config{pin}pwm[normal|invert]
returns:
OK|SYNTAXERROR|PININUSE|INVALIDPIN|INVALIDTIMERCONFIG
|OUTOFMEMORY
example:
config2pwm
{pin}:Requiredargumentindicatingthepinnumbertoassign.
[normal|invert]:Whennormal,theoutputwillnormallybelow,withthehighpulsetimecorresponding
tothedutycycle.Wheninverted,theoutputwillnormallybehigh,withthelowpulsetime
correspondingtothedutycycle.
pwm{pin}{dutycycle(0top)}
returns:
OK|SYNTAXERROR|INVALIDPIN|INVALIDVALUE
example:
pwm23000
{pin}:Requiredargumentindicatingthepinnumbertocontrol.
{dutycycle(0top)}:Requiredargumentindicatingthedutycycle.Thedutycycleasapercentis
Duty Cycle % =
duty cycle
100%
TOP
PWMFrequencyRanges
Prescaler
div1
244Hz4.00MHz
div8
30.5Hz500KHz
div64
3.81Hz62.5KHz
div256
0.954Hz15.6KHz
div1024
0.238Hz3.91KHz
June11,2011
31
http://www.mattairtech.com/
ZeptoProg
UserGuide
FrequencyOutput
Theconfigfocommandconfiguresthespecifiedpintooutputasquarewave.Notethat
althoughtwopins(1and2)canbeconfiguredtooutputafrequency,theymustsharethesame
frequency.Thefocommandcanthenbeusedtosetthefrequency.Thehigherthefrequency,the
lowertheresolutioninsettingthefrequency.Thefrequencycanbefoundusing:
F fo =
16MHz
2prescaler TOP1
config{pin}fo
returns:
OK|SYNTAXERROR|PININUSE|INVALIDPIN|INVALIDTIMERCONFIG
|OUTOFMEMORY
example:
config2fo
{pin}:Requiredargumentindicatingthepinnumbertoassign.
fo{pin}{TOPvalue(16b)}
returns:
OK|SYNTAXERROR|INVALIDPIN|INVALIDVALUE
example:
fo20x17ff
{pin}:Requiredargumentindicatingthepinnumbertocontrol.
{TOPvalue(16b)}:Requiredargumentusedtoproducetheoutputfrequency.
FrequencyOutputRanges
Prescaler Setting
div1
122Hz8.00MHz
div8
15.3Hz1.00MHz
div64
1.91Hz125KHz
div256
0.477Hz31.3KHz
div1024
0.119Hz7.81KHz
June11,2011
32
http://www.mattairtech.com/
ZeptoProg
UserGuide
FrequencyMeasurement
Theconfigficommandisusedtoconfigurethespecifiedpin(3only)asaninputtomeasure
frequencies.Optionally,afiltermaybeenabled.SeeATmega32U2datasheetfordetails.Thefi
commandcanthenbeusedtomeasurethefrequency.Thefrequencywillbecalculatedanddisplayed
inHertz.Ifnosignalispresentwhenthecommandisexecuted,thecommandwilllikelytimeoutwitha
CAPTUREOVERFLOWerror.
Thefrequencyismeasuredbycapturingthetimeforeachoftwoedgesofthesignal.Thereis
aminimumamountoftimerequiredtoelapsebetweenthesecapturesforthecapturevaluestobe
consideredreliable(128timerticks).Thisisduetointerruptlatenciesandotherfactors.Ifthis
minimumtimeisnotreached,butthesignalwasotherwisedetected,aCAPTUREOUTOFRANGE
erroroccurs.Thenexthigherfrequencyrange(lowerprescaler)canthenbeselected,ifavailable.
Notethatifthefrequencyofinterestexistswithinmultipleprescalersettings,usethelowestprescaler
settingthatstillcontainsthefrequency,asthiswillmaximizeresolution(seeInputFrequencyRanges
table).
config{pin}fi[filter]
returns:
OK|SYNTAXERROR|PININUSE|INVALIDPIN|INVALIDTIMERCONFIG
|OUTOFMEMORY
example:
config3fi
{pin}:Requiredargumentindicatingthepinnumbertoassign.
[filter]:SeeATmega32U2datasheetfordetails.
fi{pin}
returns:
FI{pin}{frequency(16b)}Hz
or
SYNTAXERROR|INVALIDPIN|CAPTUREOVERFLOW
|CAPTUREOUTOFRANGE
example:
fi3
FI37426Hz
{pin}:Requiredargumentindicatingthepinnumbertouse.
June11,2011
33
http://www.mattairtech.com/
ZeptoProg
UserGuide
FrequencyInputRanges
Prescaler Setting
Frequency Range
div1
244Hz125KHz
div8
30.5Hz15.6KHz
div64
3.81Hz1.95KHz
div256
0.954Hz488Hz
div1024
0.238Hz122Hz
June11,2011
34
http://www.mattairtech.com/
ZeptoProg
UserGuide
SerialApp
TheSerialAppisaUSBtoserialbridgethatallowsthetargetMCU(orotherdevice)to
communicatewithaPCapplication(likeaterminal)overUSB.OnthePCside,theZeptoProgwill
appearasavirtualCOMport.UnliketheSPIAppandGPIOApp,thereisnoterminalmodeor
commands.TheZeptoProgsimplyrelaysbytesbetweenthePCandtarget.
SerialAppConfiguration
BeforeusingtheSerialApp,itmustbeconfiguredtobecompatiblewiththetarget.Thisisdone
inConfigurationMode.ThereisnoneedtoduplicatethesettingsonthePCside.Communication
betweenthePCandZeptoProgwillalwaysbeasfastasUSBallows.Onlytheconnectionbetweenthe
ZeptoProgandtargetusethesesettings.
Speed
(Selectpresetspeedorselectmanual)
2400
9600
19.2K
38.4K
57.6K
76.8K
125K
250K
500K
1M
2M
Manual
(WhenexitingthismenubacktoSpeed,Manualwillthenbesetasthespeed)
BaudRateRegister
(seeATmega32U2datasheet)
EnterBaudRateRegister(16b)
(enter00000fff)
Clock2X(asynconly)
1X
2X
ClockMode
Async
(Noclockused)
Sync
(Whenselected,XCKwilloutputaclocksignal)
Polarity
SampleFalling
SampleRising
FlowControl
None
CTS
June11,2011
(Whenselected,_CTSwillbeenabledasaninput.BringhightopauseTX)
35
http://www.mattairtech.com/
ZeptoProg
UserGuide
DataBits
StopBits
Parity
None
Even
Odd
SerialConnections
TheZeptoProgshouldbepoweredbeforethetargetboard.Inallmodes,GndandVtgtmustbe
connectedtothetargetboard.TXand/orRXmustbeconnectedaswell.Wheninsynchronousmode,
theZeptoProgisthemaster,sotheXCKpinisenabledasanoutput.Thetargetboardmustenableits
clockpinasaninputandbeconfiguredasaslave.If_CTSisused,connectittothetarget_RTSline.
When_CTSislow,TXactivity(fromtheZeptoProgtothetarget)occursnormally.When_CTSis
broughthigh,TXpauses.Thispreventsbufferoverflowsonthetargetifitbecomesbusy.
Notethatwhenconfiguringthespeedtobemanual,itispossibletosetthespeedhigherthan
2MHzinsynchronousmode.WhiletheZeptoProgcanhandlecontinuousRXdataata4MHzclock,
theUSBhardwareontheATmega32U2canonlyhandle256KB/s.NotethatRXisprioritizedoverTX
andLEDhandling.Usethefollowingequationstodeterminethevaluetoenterintothebaudrate
register.
BaudRateRegisterValue(ManualSpeed)
Async 1X
f osc
1
16BAUD
UBRR=
f osc
16UBRR1
BAUD=
UBRR=
BAUD=
Async 2X
Synchronous
f osc
1
8BAUD
UBRR=
f osc
8UBRR1
BAUD=
f osc
1
2BAUD
f osc
2UBRR1
June11,2011
36
http://www.mattairtech.com/
ZeptoProg
UserGuide
SPIApp
TheSPIAppisusefulfortestingSPIdevicesorforcontrollingSPIdevicesviaPCsoftware.In
TerminalMode,theusercanuseSPIcommandstosendandreceivedatainhexorASCII.Datatobe
sentisincludedonthecommandline.NonInteractivemodealsousesSPIcommands,butdatamust
bebinaryandsentdataisnotonthecommandline.
SPIAppConfiguration
Speed
8MHz
4MHz
2MHz
1MHz
500KHz
250KHz
125KHz
SPIMode
DataOrder
MSB
LSB
DummyByte
Disabled
Enabled
(Whenenabled,MISObytesmatchingtheDummyByteValuearediscarded)
DummyByteValue
EnterDummyByte
(00ff)
SPIConnections
TheZeptoProgshouldbepoweredbeforethetargetboard.GndandVtgtmustbeconnectedto
thetargetboard.Thereareupto4chipselectoutputsonpins03.Theseareopendrainandactive
low,sothetargetdevicemusthaveapulluponitschipselectpin.
June11,2011
37
http://www.mattairtech.com/
ZeptoProg
UserGuide
SPICommands
Thereare3commands.Theyaret(transfer),w(write),andr(read).Thereare2versionsof
eachcommand.TheversionuseddependsonwhetherTerminalModeisenabledornot.Ifenabled,
anadditionalargumentisavailable(hex)anddatatobesentisentereddirectlyonthecommandline.
Ifnotenabled,hexisnotavailable,andthelengthofdatamustbespecified.Anydatatowriteissent
onlyafterthecommandisentered(newline)andthereturnvalueindicatessuccess(thecodeforOK).
IfOK,theZeptoProgwillthenreadlengthbytesfromUSB.
Thechipselectlinetouse(03)isarequiredargument.Normally,theZeptoProgholdsthe
specifiedchipselectlowonlyforthedurationofthecommand.Theoptionalargumentholdkeepsthe
chipselectlinelowbetweencommandsuntileitherholdisomitted,anotherchipselectlineis
specified,ortheSPIAppisexited.Thiscanbeusefulinterminalmodeifthelengthofdatatosend
exceedstheremainingcommandlinebufferspace,orifyouwishtomixhexadecimalandASCII.
TheoptionalhexargumentisusefultoenterbinarydatawheninTerminalMode.Ifspecified,
separatevaluescanthenbelistedseparatedbywhitespace.Valuesstartingwith0xareinterpreted
ashexadecimal,butvaluescanbeenteredindecimalaswell.Whenhexisnotspecified,all
charactersareinterpretedasASCII.
example:
w0HelloWorld!
example:
thex00xc10x000x0345
SPITransfer
TerminalMode:
t[hold][hex]0|1|2|3<TXdata(uptoremaininglinebuffersize)>
returns:
OK|SYNTAXERROR|INVALIDPIN|INVALIDHEX
action:
IfOK,TXdatafromthecommandlineissentoverSPI.Thelengthofdata
isdeterminedautomaticallyfromthecommandline.ForeachTXbyte,
anRXbyteisreadfromSPIandsentoverUSB.Ifthedummybyteisused,all
bytesfromSPIthatmatchthedummybytevaluewillbediscarded.
NonInteractiveMode:
t[hold]0|1|2|3{length(16b)}
returns:
OK|SYNTAXERROR|INVALIDPIN
action:
IfOK,lengthbytesofTXdataarereadfromUSBandsentoverSPI.Foreach
TXbyte,anRXbyteisreadfromSPIandsentoverUSB.Ifthedummybyteis
used,allbytesfromSPIthatmatchthedummybytevaluewillbediscarded.
June11,2011
38
http://www.mattairtech.com/
ZeptoProg
UserGuide
SPIWrite
TerminalMode:
w[hold][hex]0|1|2|3<txdata(uptoremaininglinebuffersize)>
returns:
OK|SYNTAXERROR|INVALIDPIN|INVALIDHEX
action:
IfOK,TXdatafromthecommandlineissentoverSPI.Thelengthofdata
isdeterminedautomaticallyfromthecommandline.
NonInteractiveMode:
w[hold]0|1|2|3{length(16b)}
returns:
OK|SYNTAXERROR|INVALIDPIN
action:
IfOK,lengthbytesofTXdataarereadfromUSBandsentoverSPI.
SPIRead
TerminalMode:
r[hold][hex]0|1|2|3{length(16b)}
returns:
OK|SYNTAXERROR|INVALIDPIN
action:
IfOK,lengthbytesofRXdataarereadfromSPIandsentoverUSB.Ifthe
dummybyteisused,allbytesfromSPIthatmatchthedummybytevaluewillbe
discarded.
NonInteractiveMode:
r[hold]0|1|2|3{length(16b)}
returns:
OK|SYNTAXERROR|INVALIDPIN
action:
IfOK,lengthbytesofRXdataarereadfromSPIandsentoverUSB.Ifthe
dummybyteisused,allbytesfromSPIthatmatchthedummybytevaluewillbe
discarded.
June11,2011
39
http://www.mattairtech.com/
ZeptoProg
UserGuide
ResponseCodesforSPIApp
Terminal Mode
Non-Interactive Mode
OK
0x00
SYNTAXERROR
0x01
INVALIDPIN
0x02
INVALIDHEX
0x0c
ExampleSession
ThisexampledemonstratescommunicationwithaSPISRAMchip(Microchip23K256)in
TerminalModeusingchipselect0withan8MHzclock.Theholdfeatureisusedtomixcommandsin
hexadecimal(anddecimal)withdatainASCII.
SPI > t hex 0 5 0
OK
FF 00
SPI > t hex 0 1 0x41
OK
07 FF
SPI > t hex 0 5 0
OK
FF 41
SPI > w hold hex 0 2 0 0
OK
SPI > r 0 12
OK
Hello World!
June11,2011
40
http://www.mattairtech.com/
ZeptoProg
UserGuide
DFUBootloader
TheZeptoProgfirmwarewillbeupdatedperiodicallytoaddnewfeaturesandfixbugs.These
updateswillbeavailableontheMattairTechwebsite.Theupdatesmayincludejustahexfile(for
programmingflash),orbothahexfileandeepfile(forprogrammingbothflashandEEPROM).
FLIP
PlugintheZeptoProgwhileholdingdownbothbuttons.ThiswillentertheDFUbootloader.
LEDAshouldbeoffandLEDBshouldbeon.NowlaunchtheFLIPutility.Whenithasloaded,click
onthechipiconandselecttheAtmega32U2.
June11,2011
41
http://www.mattairtech.com/
ZeptoProg
UserGuide
Next,clickontheUSBicon,selectUSB,thenconnect.Thescreenshouldnowshow
informationabouttheATmega32U2.ClickontheFilemenu,andopentheappropriatehexfile.More
informationwillappearabouttheprogram.Besurethateraseischecked.TheZeptoProgfirmware
cannotbeloadedunlesstheflashiserasedfirst.UncheckBlankCheck,asitisnotsupported.
Programmustbechecked.Verifymustbeunchecked.Readingoftheflashisnotallowed,so
verificationisnotpossible.VerificationislessusefulwhenprogrammingoverUSBanyway,asUSB
provideserrordetectionandcorrection.NowclickontheRunbuttoninthelowerleftofthescreen,
andthefirmwarewillbequicklyloadedontotheZeptoProg.Ifyouencounterproblems,thenyouwill
needtounplugtheZeptoProg,disconnectFLIP,andstartovermakingcertainthattheabovesettings
areobserved.
YoumayalsoneedtoprogramtheEEPROM.Ifso,clickonSelectEEPROMatthebottom.
Then,clickontheFilemenuandopentheappropriateeepfile.Youwillhavetochangethefilefilterto
allowyoutoseetheeepfile.Notethateepfilesarejusthexfilesbutwiththeeepextensioninsteadof
hex.Moreinformationwillappearaboutthefilewhenselected.BothProgramandVerifyshouldbe
June11,2011
42
http://www.mattairtech.com/
ZeptoProg
UserGuide
checked.ClickruntoprogramtheEEPROM.
dfuprogrammer
TODO
Musterasechipfirst.Cannotreadflash.
dfuprogrammeratmega32u2erase
dfuprogrammeratmega32u2flasheepromZeptoProg110111.eep(ifapplicable)
dfuprogrammeratmega32u2flashsuppressvalidationZeptoProg110111.hex
June11,2011
43
http://www.mattairtech.com/
ZeptoProg
UserGuide
LegalNotices
CopyrightNotices
Copyright
Copyright
Copyright
Copyright
2009-2011,
2009-2010,
2010, ChaN
2003-2010,
SoftwareDisclaimer
The author disclaim all warranties with regard to this software, including all
implied warranties of merchantability and fitness. In no event shall the author be
liable for any special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether in an action of
contract, negligence or other tortious action, arising out of or in connection
with the use or performance of this software.
HardwareDisclaimer
The product described in this document is subject to continuous development and
improvements. All particulars of the product and its use contained in this
document are given by MattairTech LLC in good faith. However all warranties
implied or expressed including but not limited to implied warranties of
merchantability or fitness for particular purpose are excluded.
This document is intended only to assist the reader in the use of the product.
MattairTech LLC shall not be liable for any loss or damage arising from the use of
any information in this document or any error or omission in such information or
any incorrect use of the product.
Trademarks
ZeptoProg is a trademark of MattairTech LLC.
AVR is a registered trademark of Atmel Corporation.
All other trademarks are the property of their respective owners.
Acknowledgments
Thanks to Dean Camera (http://www.fourwalledcubicle.com/) for his excellent LUFA
library, AVRISPmkII clone, and DFU bootloader, all of which are used in the
ZeptoProg firmware. Thanks to the members of AVRfreaks (http://www.avrfreaks.net/)
for their support. Finally, thanks to Atmel for creating a great product, the AVR.
June11,2011
44
http://www.mattairtech.com/
ZeptoProg
UserGuide
AppendixA:PoweringTargetviaZeptoProg5V
WARNING
Care must be taken if using the Vtgt solder jumper to output 5V to
the target board. Reverse polarity protection is not active in this
configuration, and there is no overload protection. Be sure that the
target board can operate safely when powered from the ISP
connector. Do not attempt to program XMEGA devices with 5V.
TODO
openingthecase(useflatheadscrewdriverateachcornermultipletimesaroundthe
perimeter,slowlyliftingthetop;thetopisattachedtothebottomvia4plasticpinsinsertedinto4
plasticholesateachcorner,liftingonecornertoomuchbeforelevelingoutusingtherestofthe
cornersmaybreakapin)
solderjumper(solderJ9onbottomcornertoconnectVbus5VtoVtgt,useonly5Vcompatible
targets)
June11,2011
45
http://www.mattairtech.com/
ZeptoProg
UserGuide
AppendixB:AVRProgrammerSupportedDevices
TheZeptoProgsupportsallAtmelAVRmicrocontrollerswithanISP,PDI,orTPIprogramming
interface.TheseincludethemegaAVRseries(ISP),thetinyAVRseries(ISP,TPI),theXMEGAseries
(PDI),theUSBAVRs(ISP),andthelistedCANandPWMAVRs.Thefollowinglistsmostofthe
supportedmodels.Addtothesethedifferentvoltageandspeedgradevariants.
ZeptoProgAVRProgrammermegaAVRSeriesDeviceSupport
ATmega128,ATmega1280,ATmega1281,ATmega1284,ATmega1284P,ATmega128A,ATmega16,ATmega162,
ATmega164A,ATmega164P,ATmega164PA,ATmega165,ATmega165A,ATmega165P,ATmega168,
ATmega168A,ATmega168P,ATmega168PA,ATmega169,ATmega169A,ATmega169P,ATmega169PA,
ATmega16A,ATmega16HVB,ATmega2560,ATmega2560,ATmega2561,ATmega32,ATmega324A,
ATmega324P,ATmega324PA,ATmega325,ATmega3250,ATmega3250A,ATmega3250P,ATmega325A,
ATmega325P,ATmega328,ATmega328P,ATmega329,ATmega3290,ATmega3290A,ATmega3290P,
ATmega329A,ATmega329P,ATmega329PA,ATmega32A,ATmega32C1,ATmega32HVB,ATmega32M1,
ATmega48,ATmega48A,ATmega48P,ATmega48PA,ATmega64,ATmega640,ATmega644,ATmega644A,
ATmega644P,ATmega644PA,ATmega645,ATmega6450,ATmega6450A,ATmega6450P,ATmega645A,
ATmega645P,ATmega649,ATmega6490,ATmega6490A,ATmega6490P,ATmega649A,ATmega649P,
ATmega64A,ATmega64HVE,ATmega8,ATmega8515,ATmega8535,ATmega88,ATmega88A,ATmega88P,
ATmega88PA,ATmega8A,ATmega8HVD
ZeptoProgAVRProgrammertinyAVRSeriesDeviceSupport
ATtiny10,ATtiny12,ATtiny13,ATtiny13A,ATtiny15,ATtiny167,ATtiny20,ATtiny2313,ATtiny2313A,ATtiny24,
ATtiny24A,ATtiny25,ATtiny26,ATtiny261,ATtiny261A,ATtiny4,ATtiny40,ATtiny4313,ATtiny43U,ATtiny44,
ATtiny44A,ATtiny45,ATtiny461,ATtiny461A,ATtiny48,ATtiny5,ATtiny84,ATtiny85,ATtiny861,ATtiny861A,
ATtiny88,ATtiny9
ZeptoProgAVRProgrammerXMEGASeriesDeviceSupport
ATxmega128A1,ATxmega128A1_revD,ATxmega128A1U,ATxmega128A3,ATxmega128A4,ATxmega128D3,
ATxmega128D4,ATxmega16A4,ATxmega16D4,ATxmega192A1,ATxmega192A3,ATxmega192D3,
ATxmega256A1,ATxmega256A3,ATxmega256A3B,ATxmega256D3,ATxmega32A4,ATxmega32D4,
ATxmega384A1,ATxmega64A1,ATxmega64A3,ATxmega64A4,ATxmega64D3,ATxmega64D4
ZeptoProgAVRProgrammerUSBAVRDeviceSupport
AT90USB1286,AT90USB1287,AT90USB162,AT90USB646,AT90USB647,AT90USB82,ATmega16U2,
ATmega16U4,ATmega32U2,ATmega32U4,ATmega32U6,ATmega8U2
ZeptoProgAVRProgrammerCANAVRandPWMAVRDeviceSupport
AT90CAN128,AT90CAN32,AT90CAN64,AT90PWM2,AT90PWM216,AT90PWM2B,AT90PWM3,
AT90PWM316,AT90PWM3B
June11,2011
46
http://www.mattairtech.com/