Anda di halaman 1dari 24

MT-DB-U4 UserGuide

May20,2012

http://www.mattairtech.com/

MTDBU4

UserGuide

Table of Contents
Overview........................................................................................................................3
Introduction............................................................................................................... ........................3 MTDBU4Features.................................................................................................. ........................3 ATmega32U4Features......................................................................................... ............................4

MTDBU4Hardware.....................................................................................................6
Layout/HeaderPins............................................................................................................... ..........6 PinDescriptions........................................................................................................... .....................7 HWBJumper/RESETbutton/LED.......................................................................... .......................8 ISPHeader......................................................................................................... ..............................8 JTAG........................................................................................................................... ......................9 PCBPhotos..................................................................................................................................... ..9

PowerConfiguration...................................................................................................10
BusPowered5V....................................................................................................................... .....10 ExternallyPowered3.4Vto5.5V......................................................................... .........................10 ExternallyPowered3.0Vto3.6V......................................................................... .........................10 USBShield......................................................................................................................... .............10

ArduinoCompatibility.................................................................................................11
Features............................................................................................................... ...........................11 PinMapping.................................................................................................................................... .11 Installation.................................................................................................................... ...................12 UsingArduino......................................................................................................................... .........12 UsingLibraries................................................................................................... .............................12 USBSerialinterface..................................................................................................... ...................13

CDCBootloader(Arduino/AVRDUDE)......................................................................14
CDCSerialDriver............................................................................................................. ...............14 CDCBootloader..................................................................................................... .........................14

DFUBootloader(FLIP/dfuprogrammer)..................................................................15
Installation.................................................................................................................... ...................15 FLIP............................................................................................................................................... ..16 dfuprogrammer.......................................................................................................................... .....18

RunningBitlashDemo...............................................................................................19
Bitlash................................................................................................................. ............................19

Schematic....................................................................................................................21 About............................................................................................................................22
ContactInformation............................................................................................................. ............22 SupportInformation...................................................................................................................... ...22 Precautions................................................................................................................. ....................22

Legal.............................................................................................................................23

May20,2012

http://www.mattairtech.com/

MTDBU4

UserGuide

Overview
Introduction
TheMTDBU4isadevelopmentboardfortheAtmelATmega32U4USBmicrocontrollerwith Arduinosupport.Theboardhas40pinsinadualinlineconfigurationwith100milpinspacingand700 milrowspacingwhichallowsformountingonabreadboard.ItincludesaminiUSBconnector,status LED,16MHzcrystal,resetbutton,HWBbootjumper,andISPheader.Abootloadercomespreinstalled whichallowsprogrammingofthechipoverUSBwithoutanexternalprogrammer.TheISPheadercan beusedwithanexternalprogrammerforinsystemprogramming.Thisheadercanbereconfiguredto allowtheMTDBU4itselftobeanISPprogrammer,ortobeusedasaSPImasterorslave.Theboard canbepoweredviaUSBat5Voritcanbeexternallypowered(3V5.5V).AllprogrammableIOpins areroutedtoheaders,includingthoseusedbyonboardhardware.Thechipcanbeclockedexternally, andtheboardiscompatiblewithHVprogramming.TheUSBconnectionsarealsoroutedtoheader pins,whichallowsforpanelmountUSBconnectors.Theanalogpowerrailisfiltered.ThePCBishigh qualitywithENIG(goldplated)finish,redsoldermask,andwhitescreenprintingshowingthepinout.It measuresapproximately2.1x0.9(52mmx23mm)andis0.062(1.6mm)thick.

MTDBU4Features

ATmega32U4USBmicrocontroller 32KBFLASH,2.5KBSRAM,1KBEEPROM 1210bitADCchannels(1usedbyLED) SerialUSART,SPI,andTWI(I2C)communications 4timerswith14PWMchannels(upto7simultaneous)

Arduinocompatible CDC(Arduino/AVRDUDE)orDFU(FLIP)bootloaderpreinstalled Bitlashpreinstalled(Arduinocommandshell)

ISPheader(programchipusingexternalprogrammer) 16MHzcrystal GreenStatusLED Resetbutton Bootloaderselectionjumper MiniUSBconnector PoweredbyUSBorexternalpowersupply 5V(USB)or3V5.5V(external) Allpinsroutedtoheaders(includingthoseusedbyonboardhardware) Canbemountedonabreadboard USBpinsroutedtoheaderpins(forpanelmountUSBconnector) Inductoronanalogsupplywithseparategroundpin HighqualityPCBwithgoldplatedfinish Measuresapprox.2.1x0.9(52mmx23mm)and0.062(1.6mm)thick.

May20,2012

http://www.mattairtech.com/

MTDBU4

UserGuide

ATmega32U4Features
High Performance, Low Power AVR 8-Bit Microcontroller Advanced RISC Architecture 135 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static Operation Up to 16 MIPS Throughput at 16 MHz On-Chip 2-cycle Multiplier Non-volatile Program and Data Memories 32K Bytes of In-System Self-Programmable Flash 2.5K Bytes Internal SRAM 1K Bytes Internal EEPROM Write/Erase Cycles: 10,000 Flash/100,000 EEPROM Data retention: 20 years at 85C/ 100 years at 25C Optional Boot Code Section with Independent Lock Bits In-System Programming by On-chip Boot Program True Read-While-Write Operation All supplied parts are preprogrammed with a default USB bootloader Programming Lock for Software Security JTAG (IEEE std. 1149.1 compliant) Interface Boundary-scan Capabilities According to the JTAG Standard Extensive On-chip Debug Support Programming of Flash, EEPROM, Fuses, and Lock Bits through the JTAG Interface USB 2.0 Full-speed/Low Speed Device Module with Interrupt on Transfer Completion Complies fully with Universal Serial Bus Specification Rev 2.0 Supports data transfer rates up to 12 Mbit/s and 1.5 Mbit/s Endpoint 0 for Control Transfers: up to 64-bytes 6 Programmable Endpoints with IN or Out Directions and with Bulk, Interrupt or Isochronous Transfers Configurable Endpoints size up to 256 bytes in double bank mode Fully independent 832 bytes USB DPRAM for endpoint memory allocation Suspend/Resume Interrupts CPU Reset possible on USB Bus Reset detection 48 MHz from PLL for Full-speed Bus Operation USB Bus Connection/Disconnection on Microcontroller Request Crystal-less operation for Low Speed mode Peripheral Features On-chip PLL for USB and High Speed Timer: 32 up to 96 MHz operation One 8-bit Timer/Counter with Separate Prescaler and Compare Mode Two 16-bit Timer/Counter with Separate Prescaler, Compare- and Capture Mode One 10-bit High-Speed Timer/Counter with PLL (64 MHz) and Compare Mode Four 8-bit PWM Channels Four PWM Channels with Programmable Resolution from 2 to 16 Bits Six PWM Channels for High Speed Operation, with Programmable Resolution from 2 to 11 Bits Output Compare Modulator 12-channels, 10-bit ADC (features Differential Channels with Programmable Gain) Programmable Serial USART with Hardware Flow Control Master/Slave SPI Serial Interface Byte Oriented 2-wire Serial Interface Programmable Watchdog Timer with Separate On-chip Oscillator On-chip Analog Comparator Interrupt and Wake-up on Pin Change On-chip Temperature Sensor Special Microcontroller Features

May20,2012

http://www.mattairtech.com/

MTDBU4

UserGuide

Power-on Reset and Programmable Brown-out Detection Internal 8 MHz Calibrated Oscillator Internal clock prescaler & On-the-fly Clock Switching (Int RC / Ext Osc) External and Internal Interrupt Sources Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby, and Extended Standby I/O and Packages All I/O combine CMOS outputs and LVTTL inputs 26 Programmable I/O Lines 44-lead TQFP Package, 10x10mm 44-lead QFN Package, 7x7mm Operating Voltages 2.7 - 5.5V Operating temperature Industrial (-40C to +85C) Maximum Frequency 8 MHz at 2.7V - Industrial range 16 MHz at 4.5V - Industrial range

May20,2012

http://www.mattairtech.com/

MTDBU4

UserGuide

MTDBU4Hardware
Layout/HeaderPins

May20,2012

http://www.mattairtech.com/

MTDBU4

UserGuide

PinDescriptions Pin
Gnd 5V,Vbus Vcc Digitalground 5VoutputfromUSBVbus.Vbuspinistiedto5Vpin.Thesepinsare connectedtotheVbusandUVccpinsofthemicrocontroller. Voltageinputpin.UsesolderjumperJ1toconnectthispinto5V(default setting)whenusingUSBpower.Inthiscase,Vccisanoutput.LeaveJ1 unconnectedtosupplypowerfromanexternalsourcetotheVccpin.This pinisconnectedtotheVccandAVccpinsonthemicrocontroller,aswell astheISPheaderandresetpullup.SeePowerConfigurationSection. 3.3Voutputfromthemicrocontrollersinternal3.3Vregulator.Thispinis connectedtoUcaponthemicrocontroller. Voltageinputtotheanalogsectionofthemicrocontroller.Thispinis connectedtoVccthrougha10uHinductorand100nFcapacitorand providespowertothemicrocontrolleranalogsection(Avccpin). Voltageinput.ThisisthereferencevoltageusedbytheADCinthe microcontroller.DONOTconnectifusinganinternalreference. Analogground Connectstoresetpinofmicrocontrolleraswellastheresetbutton.A10K pullupresistorand100nFcapacitorareconnectedtothispin. ThispinisconnectedtotheHWBjumper.Thejumperisconnectedto groundthrougha240ohmresistor.Thepinissampledafterallreset sources,includingpowerup.Ifthepinislow(HWBjumperinstalled),then thebootloaderisrun.Ifthepinishigh(HWBjumperremoved),thenthe userapplicationisrun.ThispinfunctionsasanormalGPIOpinatallother times.The240ohmresistorprovidesshortcircuitprotectionincasethe pinisusedasanoutputandthejumperisinstalled. ThegreenstatusLEDisconnectedtothispin.TheLEDisconnectedto groundthrougha240ohmresistor.Theuserapplicationisfreetousethis LED.DrivethepinhightoturnontheLED. Thispinisconnectedtotheonboard16MHzcrystal.Ifusinganexternal clock,connectittothispinandconfigurethemicrocontrollerfusestouse anexternalclock.ThisisalsousefulforHVprogrammingorrecoveryfrom incorrectlysetfuses. Thispinisconnectedtotheonboard16MHzcrystal.Thispinisuseful alongwithxtal1toconnectanexternalcrystal.Inthiscase,youmust uninstalltheonboardcrystal.

Description

3.3V Avcc

Aref Agnd RST E2/HWB

D7/LED

xtal1

xtal2

E6,F0,F1,F4,F5,F6, Thesearegenerallyusedasanalogpins.Analoggroundplanerunsunder F7 thesepins.Consultdatasheetforfunctionality. Allotherpins Consultdatasheetforfunctionality.

May20,2012

http://www.mattairtech.com/

MTDBU4

UserGuide

HWBJumper/RESETbutton/LED
TheHWBJumperisusedtoselecteitherthebootloaderoruserapplication.Thepinis sampledafterresetorpowerup.NotethatthehardwareHWBfunctionoftheATmega32U4is disabled.Thatis,theHWBEfuseisdisabled.Thebootloaderstartupcodeisalwaysrunafterresetor powerup(BOOTRSTfuseisset).ThecodesamplesthestateoftheHWBpin.Ifthepinislow,the bootloadercontinuestorun.Ifthepinishigh,theuserapplicationisrun.ThegreenLEDwillpulseon andoffusingacontinuouslychangingPWMperiodwhenthebootloaderisrunning.Ifthepreinstalled demoprogramisrunning,itwillbelitwhenUSBisconnected.Otherwise,thestateoftheLEDis controlledbytheuserapplication.Thebootloaderalwaysrunsat8MHz,whichiscompatiblewith lowervoltages.Theusermaysetthecpuspeedto16MHzinsoftware,ifrunningat5V. Itisnotnecessarytoremoveandreplacethejumperwhenswitchingbetweenthebootloader andtheuserapplication.Thejumpercanbelefton.AfterFLASHprogramming,theCDCbootloader willautomaticallyjumptotheapplication.IfusingtheDFUbootloader,thenyoucancommandFLIPor dfuprogrammertojumptotheapplication.Then,whenrunningtheapplication,theresetbuttoncan bepressedtoreenterthebootloader.Thisisusefulwhenwritinganddebuggingfirmware.Whenthe firmwareiscomplete,thejumpercanberemovedsothatfutureresetswillalwaysruntheapplication.

ISPHeader
TheISPheaderisconfiguredbydefaulttoallowISPprogrammingusinganexternal programmer.Thatis,RESETisroutedtopin5.Pin1ismarkedontheboard(itisthepinclosestto thechip).TheISPheadercanbereconfiguredsothatpinPB0(SS)isconnectedtopin5ratherthan RESET.ThiscanbedonebyswitchingsolderjumperJ2,nexttotheISPheader,totheposition oppositetotheISPlabel.ThisallowstheMTDBU4tobeusedasanAVRISPmkIIprogrammer itself,usingDeanCamera'sAVRISPmkIIsoftwareavailableathttp://www.fourwalledcubicle.com/.A precompiledhexfilewillbemadeavailableathttp://www.mattairtech.com/ontheMTDBU2product page.NotethatwhenusingtheISPheaderinthisway,Vccandgroundareoutputtothetargetboard. Therefore,thetargetboardshouldnotbepowereditself.Youshouldalsoverifythatitissafetopower thetargetboardthroughtheISPconnector.AnotherusefortheISPheaderconfiguredwithSSonpin 5istomakeuseofSPI,eitherasamasterorslave.SPIcanalsobeusedonthenormalDILheaders.

May20,2012

http://www.mattairtech.com/

MTDBU4

UserGuide

JTAG
JTAGcanbeusedforprogramminganddebugging.WhilethereisnoJTAGheader,allJTAG signalsareavailableontheDILheaderpins.FourJTAGsignalsaresharedwithADCpins(F4F7). JTAGisenabledwhilerunningthebootloaderonly.Itisdisabledwhentheuserapplicationisrunto allowaccesstotheADCpins.Itcanbereenabledinsoftware.

PCBPhotos

May20,2012

http://www.mattairtech.com/

MTDBU4

UserGuide

PowerConfiguration
BusPowered5V
Bydefault,theMTDBU4isconfiguredfor5VfromtheUSBconnector(Vbus).Inthis configuration,solderjumperJ1issettothe5Vposition.Thisshorts5V(Vbus)toVcc.Thus,the5V andVccpinsarebothoutputs.The3.3VpinisalsoanoutputfromtheAVRinternalregulator,which mustbeenabled.Thispincansupplyabout55mA.

ExternallyPowered3.4Vto5.5V
Inthisconfiguration,disconnectsolderjumperJ1(notsetto5Vor3.3V).Thensupply3.4Vto 5.5VtotheVccpin,whichisnowaninput.The5Vpinstilloutputs5VwhentheUSBcableisplugged in.The3.3VpinisalsoanoutputfromtheAVRinternalregulator,whichmustbeenabled.Thispincan supplyabout55mA.Notethatwhenusingavoltagelessthan4.5V,theAVRshouldbesettorunat 8MHzorless.Thiscanbedoneinsoftwareusingtheprescaler(noneedtochangethecrystal).

ExternallyPowered3.0Vto3.6V
Inthisconfiguration,changeyourcodetodisabletheinternal3.3Vregulator.Disconnectsolder jumperJ1(notsetto5Vor3.3V).Thensupply3.0Vto3.6VtoboththeVccpinandthe3.3Vpin, whicharenowbothinputs.Alternatively,thesolderjumperJ1canbesettothe3.3Vpositionsothat onlytheVccpinneedbeconnected.NotethatunliketheAT90USBXX2orATmegaXXU2,theinternal 3.3VregulatorcannotbeusedtopowerVccbecausetheregulatorisdisabledonresetorpowerup. Alsonotethatifthebootloaderissettorun(HWBjumperinstalled)theregulatorwillbeenabled.The regulatoristhendisabledbeforejumpingtotheuserapplication.Theregulatorisneverenabledifthe applicationisconfiguredtorun(HWBjumpernotinstalled).Therefore,ifthebootloaderistobeused inthisconfiguration,only3.3VshouldbeconnectedtoVcc.The5Vpinstilloutputs5VwhentheUSB cableispluggedin.Inthisconfiguration,theAVRshouldbesettorunat8MHzorless.Thiscanbe doneinsoftwareusingtheprescaler(noneedtochangethecrystal).

USBShield
JumperJ3canbesolderedtoconnecttheUSBshieldtoground.TheUSBspecificationcalls fortheUSBshieldtobeconnectedtogroundonthehostsideonly.However,someprefertohaveit groundedonthedevicesideaswell,thoughagroundloopwouldbeformed.An0603SMT componentmaybesolderedonthesolderjumperpadsaswell.

May20,2012

10

http://www.mattairtech.com/

MTDBU4

UserGuide

ArduinoCompatibility
Features

ArduinocoreandlibrariesportedtoMattairTechUSBboards 26digital,11analog,7PWM,5INT,8PCINT,TWI,SPI,32KBFLASH,2.5KBSRAM,1KBEEPROM USBSerialinterfacereplacesUSART0(USART1alsoavailable;canbeusedatthesametime)


Hardwaremaximumspeedof8Mbps Canuseterminalemulatororserialmonitor LEDblinkswhendataistransferred(canbedisabled) UsesthesamemethodsastheoriginalHardwareSerial.cpp(ie:Serial.println("Hello!")) BasedonLUFAUSBlibrarybyDeanCamera(www.fourwalledcubicle.com)

Arduino/AVRDUDEcompatibleCDCbootloaderpreinstalled(DFUbootloaderalsoavailable) BitlashArduinocommandinterpreter(bitlash.net)preinstalled AlllibrariesincludedwithArduinodownloadarenowsupported Bootloaderautomaticallyjumpstosketchafteritisuploaded,resetbuttonreturnstobootloader

PinMapping

May20,2012

11

http://www.mattairtech.com/

MTDBU4

UserGuide

Installation
ItisrecommendedtoinstallthisseparatelyfromexistingArduino1.xinstallations. 1. DownloadandinstallArduinoversion1.0.1rc2from http://arduino.cc/forum/index.php?topic=100503.0 2. DownloadtheMattairTech_Arduino_1.0.1rc2.zipfilefromhttp://www.mattairtech.com/(see productpage).Unzipthisfileintoyourarduinouserdirectory(ie:MyDocuments/Arduino).You mayneedtocreatethisfolder.Donotunzipintothearduinosystemdirectoryfromstep1.If youinstalledapreviousversionoftheMattairTechArduinoport,moveorremoveit.ItisOKif thereareothercores,libraries,orsketchesalreadypresent. 3. Replacethefile<arduinosystemdirectory>/hardware/tools/avr/etc/avrdude.confwith<arduino userdirectory>/hardware/MattairTech/install/avrdude.conf 4. Now,plugintheboardwiththejumperinstalledsothatthebootloaderruns.Pointthedriver installertothedirectory<arduinouserdirectory>/hardware/MattairTech/installtoinstall MattairTech_CDC.inf.ThissamedriverisalsousedfortheUSBserialinterface(ifused).

UsingArduino
WithintheArduinoIDE,selecttheappropriateMattairTechboardandCOMport.Thereare2 configurationsforeachboard,16MHz(5V)and8MHz(3.3V).Youmayselect8MHzevenifusing5V. Whenoperatingat3.3V,youshouldselect8MHz.Operatingat16MHzat3.3Visoutofspec,but shouldworkfineatroomtemparatures.WhenusingtheUSBserialinterface,itisnolongernecessary toincludetheLUFAUSBlibraryheaderfile.Then,compileanduploadyoursketchtheusualway.Note thatwhenusingaterminalemulatortocommunicatewiththeboard,besuretodisconnectbefore switchingtothebootloader.Ifthejumperislefton,theresetbuttoncanbeusedtoswitchfromthe sketchtothebootloader.Whenthesketchhasfinisheduploading,itwillrunautomatically.Ifyou installedthebootloaderyourself,besurethattheBOOTRSTfuseisset.

UsingLibraries
ThereareseverallibrariesincludedwithArduino.Someoftheseneededtobeportedtowork withMattairTechboards.Ifalibrarywasported,itisincludedintheMattairTechdownloadand installedintheArduinouserdirectorywith"_MattairTech_Port"appendedtothenameoftheoriginal directoryname.ThiscanbeseenintheArduinoIDEinFile>Sketchbook>librariesandFile >Examples.IfyouseetheFiles>Examplesversionofaparticularlibrarythenyoumustuseitinstead oftheoriginallibrarywhichwillstillbeshownloweronthemenu.IfthereisnoFiles>Examples version,thenyoumustusetheoriginal,whichdidnotrequireporting.Ifthereisalibraryyouwouldlike tousethatisnotincludedwithArduino,emailsupportandIshouldbeabletoquicklysupportit.Often, onlypinmappingsneedtobechanged.

May20,2012

12

http://www.mattairtech.com/

MTDBU4

UserGuide

USBSerialinterface
TheLUFAdirectorycontainsareorganizedsubsetoftheLUFAUSBlibrarybyDeanCamera (fourwalledcubicle.com).ItimplementsaCDCclassdevice,whichappearsasaCOMportonthehost computer.AterminalemulatorortheArduinoserialmonitorcanbeusedtocommunicatewiththe board.UsethisinterfacethesamewayyouwouldonastandardArduino(ie:Serial.println()).The interfaceisnearlythesameastheoneinHardwareSerial.cpp.Forexample:
void setup() { // If a baudrate is passed to setup(), it will be ignored and the default setting for the LED and autoflush is used Serial.begin( USB_LED_ENABLED | USB_AUTOFLUSH_ENABLED ); // this is the default setting pinMode(2, INPUT); }

void loop() { int sensorValue = digitalRead(2); Serial.println(sensorValue, DEC); //Serial.flush(); delay(1000); } // needed if autoflush is not used

Serial.beginsetsuptheUSBserialinterface.Notethatthebuadrateisignoredifused.The fastestspeedsupportedisalwaysused(2MbpsfortheAT90USB162andATmega32U2,8Mbpsforthe ATmega32U4).TherearetwooptionsthatcanbepassedtoSerial.begin().IfUSB_LED_ENABLEDis set,thentheLEDwilldisplaythestateoftheUSBconnection(onwhenconnected)aswellasblink whendataistransferred.Otherwise,theLEDwillbeleftonandyoucanmanuallycontrolit.The defaultsettingisenabled.IfUSB_AUTOFLUSH_ENABLEDisset,theupstreambuffer(tothePC)will beflushedatperiodicintervals.ThehardwareUSBDPRAMisusedfortheRXandTXbuffers.There areactuallytwobuffersperdirectioninapingpongconfiguration.Asonebufferfillsup,itisswapped withtheother,allowingtheUSBhardwaretoreadfromthefilledone,andtheusertowritetothe emptyone.Anynumberofcharacterscanbesenttotheupstreambufferwithoutanyneedtomanage it,butitmustbeflushedattheendofthetransmissionifUSB_AUTOFLUSH_ENABLEDisnotset.In thiscase,useSerial.flush().Thedefaultsettingforautoflushisenabled.

May20,2012

13

http://www.mattairtech.com/

MTDBU4

UserGuide

CDCBootloader(Arduino/AVRDUDE)
CDCSerialDriver
TheCDCSerialdriverallowstheboardtoappearasaCOMport.Thedriveritselfisincluded withWindows,butan.inffileisneededtoconfigureit.DownloadMattairTech_CDC.inffromtheMT DBU4pageathttp://www.mattairtech.com/.Youmayneedtorenamethefilesothatithastheinf extension.Next,plugintheboardwiththejumperremoved.Windowswillthenpromptyouforthe MattairTechCDCSerialdriver.Pointtheinstallertothedirectorywhereyoudownloadedthedriverand install,ignoringanywarnings.Oncethedriverisloaded,thedevicewillappearastheMattairTech CDCSerialdeviceusingaCOMportinthedevicemanager. Ifyouwish,doubleclickontheCDCSerialdeviceentryinthedevicemanagertoconfigurethe driver.Nothingontheportsettingstabneedstobechanged.WeareusingavirtualCOMportsothe settingsareignored.Thebaudratewillalwaysbeasfastaspossible.Ontheadvancedtab,youcan adjusttheFIFObuffersizes.Ifyouexperienceanybufferingproblems(ie:adelayedresponsetouser input),thenchangebothbuffersizesto1.

CDCBootloader
TheCDCbootloaderusestheAVR109protocol,andcanbeusedwithingtheArduino environment,ordirectlywithAVRDUDE.IfyoudidnotinstallArduinoforMattairTechUSBboards, thenyoumustreplacethedefaultavrdude.conffilewiththeoneprovidedinthearduino_MTUx.zipfile fromhttp://www.mattairtech.com/(seeArduinoinstallation).Thebootloaderwilljumptotheuser applicationattheendofFLASHprogramming.OtheroperationswithAVRDUDE,likewritingthe EEPROM,willnottriggerthis.Justpressresettogetbacktothebootloader(aslongasthejumperis installed).Ifusingaterminalemulator,youmustfirstdisconnectbeforerunningthebootloader.Note thatiftheuserapplicationenablesthewatchdogtimer,thenthebootloaderwillnotrunwhenresetis pressed(theuserapplicationwill).Inthiscase,onlyapoweronresetwillenterthebootloader. ExampleforWindows:
avrdude -p m32u4 -c avr109 -P COM5 -U flash:w:"bitlashdemo_MT-DB-U4.hex"

ExampleforLinux:
avrdude -p m32u4 -c avr109 -P /dev/ttyACM0 -U flash:w:"bitlashdemo_MT-DB-U4.hex"

Arduinoenvironment: BesuretoselecttheCOMport.ThenuploadyoursketchwiththeUploadbutton.

May20,2012

14

http://www.mattairtech.com/

MTDBU4

UserGuide

DFUBootloader(FLIP/dfuprogrammer)
Installation
FLIPisagraphicalutilityusedtoloadfirmwareintotheATmega32U2.FLIPincludestheDFU bootloaderdriver.ItsupportsWindowsXPthroughWindows7(32or64bit).DownloadFLIP3.4.2or higherfromhttp://www.atmel.com/dyn/products/tools_card.asp?tool_id=3886andinstall. OnceFLIPisinstalled,theDFUbootloaderdriverscanbeloaded.InstalltheHWBjumperand poweruptheboard(orpressreset).ThiswillentertheDFUbootloader.TheLEDshouldbepulsing. WindowswillthenpromptyoufortheATmega32U2driver.Bydefault,thisislocatedintheProgram Files/Atmel/Flip3.4.2/usbdirectory.Pointtheinstallertothatdirectoryandinstall.Ifrequiredtoinstall signeddriversandtheAtmeldriversdonotwork,downloadthesigneddriversat http://www.avrfreaks.net/index.php?module=Freaks%20Academy&func=viewItem&item_type=project& item_id=2196andinstall.Oncethedriverisloaded,thedevicewillappearastheATmega32U2device underAtmelUSBDevicesinthedevicemanager.

May20,2012

15

http://www.mattairtech.com/

MTDBU4

UserGuide

FLIP
InstalltheHWBjumperandpoweruptheboard(orpressreset).ThiswillentertheDFU bootloader.TheLEDshouldbepulsing.NowlaunchtheFLIPutility.Whenithasloaded,clickonthe chipiconandselecttheAtmega32U4.

May20,2012

16

http://www.mattairtech.com/

MTDBU4

UserGuide

Next,clickontheUSBicon,selectUSB,thenconnect.Thescreenshouldnowshow informationabouttheATmega32U4.ClickontheFilemenu,andopentheappropriatehexfile.More informationwillappearabouttheprogram.Besurethateraseischecked.Thefirmwarecannotbe loadedunlesstheflashiserasedfirst.Programmustbechecked.Verifyshouldalsobechecked.Now clickontheRunbuttoninthelowerleftofthescreen,andthefirmwarewillbequicklyloadedontothe ATmega32U4.

YoumayalsoprogramtheEEPROM.Ifso,clickonSelectEEPROMatthebottom.Then,click ontheFilemenuandopentheappropriateeepfile.Youwillhavetochangethefilefiltertoallowyou toseetheeepfile.Notethateepfilesarejusthexfilesbutwiththeeepextensioninsteadofhex.More informationwillappearaboutthefilewhenselected.BothProgramandVerifyshouldbechecked. ClickruntoprogramtheEEPROM. Youcanrunyourapplicationwithoutremovingthejumperorpressingresetbyuncheckingthe resetboxandpressingtheStartApplicationbutton(lowerright).

May20,2012

17

http://www.mattairtech.com/

MTDBU4 dfuprogrammer

UserGuide

dfuprogrammerisacommandlineutilityusedtoprogramtheATmega32U4thatrunsunder Linux.ADFUdriverinstallationisnotrequired.Downloadversion0.5.4orhigherfromhttp://dfu programmer.sourceforge.net/.Thefollowingcommandscanbeused:


dfu-programmer atmega32u4 erase dfu-programmer atmega32u4 flash-eeprom YourHex.eep (if applicable) dfu-programmer atmega32u4 flash YourHex.hex dfu-programmer atmega32u4 start (to jump to application section without reset)

May20,2012

18

http://www.mattairtech.com/

MTDBU4

UserGuide

RunningBitlashDemo
Bitlash
Bitlashisanopensourceinterpretedlanguageshellandembeddedprogrammingenvironment. ThepreinstalledBitlashdemowascompiledintheArduinoenvironmentandsupportsArduino functions(ie:dw()fordigitalWrite()).Aterminalemulator(recommended)ortheArduinoserialmonitor maybeused.SeetheCDCBootloadersectionfordetailsoninstallingtheCDCSerialdriver.The followingexamplesavesthreefunctionstoEEPROM.Itisthenruninthebackground,pulsingtheLED usinganalogwrite(PWM):

bitlash here! v2.0RC4 (c)2011 Bill Roy, bitlash.net -type HELP- 1706 bytes free > print free, " bytes free" 1702 bytes free > pinMode(25,1) > d25=1 > x=255;d=0; > function brighter {if (x==255) {d=0;} else { a25=++x; snooze(2);}} saved > function dimmer {if (x==0) {d=1;} else {a25=--x; snooze(2);}} saved > function pulseLED {if (d==0) {dimmer();} else {brighter();} saved > ls function brighter {if (x==255) {d=0;} else { a25=++x; snooze(2);}}; function dimmer {if (x==0) {d=1;} else {a25=--x; snooze(2);}}; function pulseled {if (d==0) {dimmer();} else {brighter();}; > run pulseled > ps 0: pulseled > stop 0 >

DocumentationforBitlashisavailableathttp://bitlash.net/wiki/docindex
arg else function help if ls peep print ps return rm run stop switch while abs ar aw bc beep br bs bw constrain delay dr dw er ew free inb max millis min outb pinmode printf pulsein random shiftout sign snooze

Commands

Functions

May20,2012

19

http://www.mattairtech.com/

MTDBU4 OldDemoProgram

UserGuide

TheolddemoprogrammakesusetheuseoftheMTDBU4asaCDCdevice(virtualCOM port).ThisisoneofthemostcommonwaystoconnecttoaPCoverUSB.ItusesDeanCamera's opensourceLUFAUSBlibraryavailableathttp://www.fourwalledcubicle.com/.TheLUFAdownload includesmanyexamplesthatcanbeeasilycompiledfortheATmega32U4. SeetheCDCBootloadersectionfordetailsoninstallingtheCDCSerialdriver.Theolddemo requiresanANSIterminaltoallowdrawingofthemenusystem.Ifyouseegarbageontheterminal screen,clickontheconfigurationiconandchangetheemulationtoANSI(orANSIW).After connecting,amessagethatreadsPressanyKeyisprintedperiodically.Ifyoudonotseethis message,justpressanykeytocontinue.

May20,2012

20

http://www.mattairtech.com/

MTDBU4

UserGuide

Schematic

May20,2012

21

http://www.mattairtech.com/

MTDBU4

UserGuide

About
ContactInformation
Justin Mattair MattairTech LLC PO Box 1079 Heppner, OR 97836 USA 541-626-1531 justin@mattair.net http://www.mattairtech.com/

SupportInformation
PleasechecktheMattairTechwebsite(http://www.MattairTech.com/)forsupportinformation, includingfirmwareanddocumentationupdates.Pleasefeelfreetocontactmeusingtheaboveemail addressorphonenumber(emailisbest).SupportforAVRsingeneralcanbefoundatAVRfreaks (http://www.avrfreaks.net/).There,Imonitortheforumssectionastheuserphysicist.

Precautions

CAUTION
Do not change power configuration while unit is powered. Do not short 5V, Vbus, 3.3V, Avcc, or ground to each other. When connecting Aref externally, connect to a voltage source <= Vcc and be sure that the internal reference is disabled.

CAUTION
The MT-DB-U4 contains static sensitive components. 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.

May20,2012

22

http://www.mattairtech.com/

MTDBU4

UserGuide

Legal
Copyright Notices
Portions of this code are copyright (c) 2009-2011 Justin Mattair (www.mattairtech.com) This code uses the LUFA USB library Copyright (C) 2011, Dean Camera (www.fourwalledcubicle.com) and distributed under a modified MIT license (see files). The CDC and DFU bootloaders are modified versions from LUFA. The Arduino core files are copyright (c) 2005-2011 David A. Mellis (www.arduino.cc), copyright (c) 2004-2010 Hernando Barragan (wiring.org.co), copyright (c) 2006 Nicholas Zambetti, and copyright (c) 2009 Brett Hagman. They were modified by Justin Mattair and retain the LGPL 2.1 license (see files). The Bitlash files are Copyright (C) 2008-2011 Bill Roy (bitlash.net) They were modified by Justin Mattair and retain the LGPL 2.1 license (see files). Portions of this code are copyright 2003-2010, Atmel Corporation (http://www.atmel.com/)

SoftwareWarrantyDisclaimer
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
This development board/kit is intended for use for FURTHER ENGINEERING, DEVELOPMENT, DEMONSTRATION, OR EVALUATION PURPOSES ONLY. It is not a finished product, and may not (yet) comply with some or any technical or legal requirements that are applicable to finished products, including, without limitation, directives regarding electromagnetic compatibility, recycling (WEEE), FCC, CE, or UL (except as may be otherwise noted on the board/kit). MattairTech LLC supplied this board/kit AS IS, without any warranties, with all faults, at the buyer's and further users' sole risk. The user assumes all responsibility and liability for proper and safe handling of the goods. Further, the user indemnifies MattairTech LLC from all claims arising from the handling or use of the goods. Due to the open construction of the product, it is the user's responsibility to take any and all appropriate precautions with regard to electrostatic discharge and any other technical or legal concerns. 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
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 and DFU bootloader, which are used in the MT-DB-U4 firmware. Thanks to the members of AVRfreaks

May20,2012

23

http://www.mattairtech.com/

MTDBU4

UserGuide

(http://www.avrfreaks.net/) for their support. Finally, thanks to Atmel for creating a great product.

May20,2012

24

http://www.mattairtech.com/

Anda mungkin juga menyukai