Developing for the EFM32GG-STK3700 Development Board
Total Page:16
File Type:pdf, Size:1020Kb
Universidade Federal do Espírito Santo Developing for the EFM32GG-STK3700 Development Board All source code including text of this document is available at https://github.com/hans-jorg/efm32gg-stk37 -gcc-cmsis Hans-Jörg Schneebeli 2018 MIT License Copyright (c) 2018 Hans Jorg Andreas Schneebeli Per ission is hereby granted! "ree o" charge, to any person obtaining a copy o" this so"t#are and associated docu entation %les (the &So"t#are"), to deal in the So"t#are witho$t restriction! incl$ding witho$t li itation the rights to $se, copy! odi"y! erge, p$blish! distrib$te, s$blicense, and'or sell copies o" the So"t#are, and to per it persons to #ho the So"t#are is "$rnished to do so! s$b(ect to the "ollowing conditions) *he abo+e copyright notice and this per ission notice shall be incl$ded in all copies or s$bstantial portions o" the So"t#are. *HE S./*0A1E 2S PR.324-4 &AS 2S&! 02*H.5T 0A11A6*7 ./ A67 8264! -9PR-SS .1 2MPLI-4! 26CLU426G =5T 6OT ;2:2*-4 TO *HE 0A11A6*2-S ./ :-1CHA6*A=2;2*7! /2*6ESS /.1 A PA1*2C5LA1 P51POSE A64 6.626/126<-:-6*, 26 6O -3-6T SHALL THE A5TH.1S .1 COP712GHT H.;4-1S =E ;2A=LE /.1 A67 CLA2:! 4AMA<-S .1 .*H-1 ;2A=2;2*7! 0H-*H-1 26 A6 ACT2.6 ./ CON*1ACT, *.1T .1 OTH-102S-! A12S26G /1.:! .5T ./ .1 26 CON6ECT2.6 02TH *HE S./*0A1E .1 *HE 5SE .1 .*H-1 4EA;26GS 26 THE S./*0A1-, Version 1.0 Date 03/08/2018 Foreword *his aterial is intended as a co panion "or the lectures in a co$rse in - bedded Syste s, *he ain ob(ecti+e is to present the inner #orks o" the co pilation process and introd$ce ad+anced patterns o" so"t#are "or embedded syste s, 2t ass$ es a basic knowledge o" C. 2t consists o" any s all pro(ects! each introd$cing one, and so eti es t#o! aspects o" the de+elop ent process, Appendices show how to install the needed tools! how to $se them and the str$ct$re o" a pro(ect. Table of Contents 0 5sing C,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,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@8 18 5sing $C'OS 22,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,?A 1E 5sing $C'OS-222,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,?E 20 5sing the LCD display,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,D@ A 2nstalling the toolchain,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,80 = 5sing the tools,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,8? C Sa ple pro(ect,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,E0 The EFM32GG-STK3"## Develop%ent Board *he -/:A2 Giant Gec>o is a "a ily o" Cortex :A icrocontrollers an$"actured by Silicon Labs (who bo$ght -nergy Micro! the initial an$"act$rer), The -/:A2 icrocontroller "a ily has any s$b"a ilies with different Cortex-M architect$res and "eat$res as sho#n belo#, Family ore Feat!res Fla"h ($B) &AM ($B% !ero Gecko A#$ Cortex-M & '- 32 2- 4 (app) Gecko A#$ Cortex-M & *+, 32- -' '- 8 /in) Gecko A#$ Cortex-M3 0%1 '- 32 2- 4 "ecko A#$ Cortex-M3 0%1 2-- 22. .-1- 3ade Gecko A#$ Cortex-M3 22.-1 2' 32-24- 0eopard "ecko A#$ Cortex-M3 *+,5 L%1 -'- 24- 32 "iant Gecko A#$ Cortex-M3 *+,. L%1 422-1 2' 22. "iant Gecko S2 A#$ Cortex-M' *+,5 L%1 2 '. 422 6earl Gecko A#$ Cortex-M' 22.-1 2' 32-24- 7onder Gecko A#$ Cortex-M' *+,5 L%1 -'- 24- 32 The EMF32GG-STK3700 Development Board *he -:/A2GG-S*8AD00 is a de+elop ent board "eaturing a -/:A2<<EE0/102B MC5 (a Giant Gec>o icrocontroller) with 1 := /lash emory and 128 >= 1A:, 2t has also the "ollo#ing peripherals) • 1?0 seg ent LCD • 2 $ser b$ttons! 2 $ser ;-4s and a to$ch slider • A bient Light Sensor and ind$cti+e-capaciti+e etal sensor • -/:A2 .PAMP "ootprint • A2 := 6A64 Hash • 5S= inter"ace "or Host/4evice/.*< 2t has a 20 pin expansion header! brea>o$t pads "or easy access to 2'O pins! different 1 alternati+es "or po#er so$rces incl$ding 5S= and a 0,0A / S$per Capacitor "or bac>$p po#er do ain, /or de+eloping! there is an 2ntegrated Segger J-Link 5S= deb$gger'em$lator with deb$g o$t "$nctionality and an Ad+anced -nergy Monitoring system "or precise c$rrent tracking, *he de+elop ent board -:/A2GG-S*8AD00 "eat$res a -/:A2<<EE0/102B icrocontroller "ro the Giant Gec>o "a ily, 2t is a Cortex :A processor with the "ollo#ing "eat$res) Flash &AM GP)* USB L D +SART- ,E+'&T Timer- AD D' *pAmp #KB) #KB% +'&T (.MRTC 2 2' 12. 87 Y 8x3' 3/2 2 2 4/22 19.: 29.: 3 Basic Re erences *he ost i portant references are: 1 • -/:A2GG 1eference Man$al ) :an$al describing all peripherals! emory ap, 2 • -/:A2GG-S*8AD00 Giant <ec>o Starter Kit 5serIs <$ide ) 2n"or ation abo$t the S*8AD00 =oard, A • -/:A2<<EE0 4atasheet ) *echnical in"or ation abo$t the -:/A2<<EE0/102B incl$ding electrical speci%cations and pino$t. B • -/:A2 Microcontroller /a ily Cortex :A 1eference Man$al !eripherals *here are a lot o" peripherals in the board, • ;-4s $sing pins PE2 and PEA, • =$ttons $sing pins PBE and PB10 • LCD :$ltiplexed 20J8 with a D character alphan$ eric %eld! a B digit n$ eric %eld and other symbols $sing pins PA0-PA11! PA1@!PB0-PB?!PDE- PD12!PE4-PE7, 1 https)''###,silabs,co 'doc$ ents'p$blic're"erence- an$als'-/:A2<<-1:,pd" 2 https)''###,silabs,co 'doc$ ents'p$blic'$ser-g$ides'e" A2gg-stkAD00-$g,pd" A https)''###,silabs,co 'doc$ ents'p$blic'data-sheets'-/:A2<<EE0,pd" B https)''###,silabs,co 'doc$ ents'p$blic're"erence- an$als'-/:A2-CorteF-:A-1:,pd" 2 • *o$ch Sensor $sing pins PC8-11, • Light Sensor $sing PD?!PC6 • LC Sensor $sing PB12!PC7 • 6A64 /lash $sing PB1@! PE8-1@! PC1-2! P/8-E! PD1A-1@ • 5S= OTG $sing P/11-12! P/@-? 2t is also possible to $se the header connectors to add ore peripherals, "onnections *he -:/A2GG-S*8AD00 board has t#o 5S= connectors) .ne, a Mini 5S= = Connector! "or de+elop ent and other! a Micro =-*ype 5S= Connector! "or the application, /or de+elop ent, a cable (deli+ered) $st be connected bet#een the Mini 5S= connector on the board and the A-*ype connector on the PC. A ong the devices listed by the lsusb co and! the "ollowing $st appear, Bus 001 Device 019: ID 1366:0101 SEGGER J-Link PLUS *he S*8AD00 board has t#o icrocontrollers) one, called target, is a -/:A2<<EE0/102B icrocontroller! and the other! called =oard Controller! i plements an inter"ace "or progra ing and deb$gging, /or a Cortex M icrocontroller the "ollowing progra ing inter"aces are $sed) • S04 ) 2 pinos) S0CL8! S042O - Serial 0ire 4eb$g, • J*AG ) B pinos) TCK, *:S! *42! *4O - 6ot $sed in this board A 2n the S*8AD00 only the S04 inter"ace is $sed! and there is a connector on the S04 lines which per its the deb$gging o" off-board icrocontrollers, USB Mini B Connector SWD Host USB Board Target USB PC Controller Processor Serial Interface USB A STK3700 Board USB OTG Connector AB Connector <enerally! in this kind o" boards there is a serial inter"ace bet#een the *arget and the =oard Controller, 2t can be i plemented $sing a physical channel with 2 lines or a virtual! $sing the S04'J*AG channel, =oth appears to the Host PC as a serial virtual port (CO ! or "#ev"$$%&C !). 2n the S*8AD00 board the serial channel $ses the 5A1T0 $nit (pins PE0 and PE1). Examples for the EFM32GG-STK3700 Development Board 2n all exa ples! a direct access to registers