Vous êtes sur la page 1sur 6

CodeWarrior for HCS12 Assembly Programming

Updated 08-17-10 by: M. Mazidi with contribution from Danny Causey and ra!is Chand"er 1# $tart Code%arrior for &C$1' and c"ic( Crate )ew *ro+ect shown be"ow.

,,-f Code%arrior is a"ready runnin. you may se"ect new pro+ect from the fi"e menu or c"ic( the icon on the too" bar.

'# $e"ect the MCU to pro.ram and your connections. /ou can chan.e your connection at any time after creatin. a pro+ect0 for now we choose fu"" chip simu"ation. C"ic( )e1t.

2# $et the "ocation where the pro+ect is to be sa!ed0 and name the pro+ect as shown be"ow. Choose the "an.ua.e3s# you wi"" be usin.. Unse"ect the 45e"ocatab"e assemb"y6 then se"ect 47bso"ute assemb"y6. C"ic( )e1t.

8# Choose any fi"es your pro+ect wi"" use0 for this e1amp"e we do not need any additiona" fi"es. C"ic( )e1t. ,,/ou can a"so add fi"es to your pro+ect after it has been created.

9# Choose :)one; for 5apid 7pp"ication De!e"opment. C"ic( <inish.

=# >1pand the $ources fo"der created by Code%arrior and doub"e c"ic( main.asm as shown be"ow.

7# 5ep"ace the temp"ate code pro!ided by Code%arrior with an e1amp"e from the boo( as shown be"ow or your own code. )ote that the minima" re?uirements for an 7ssemb"y pro.ram are the fo""owin.: a# the 7@$>) 5/ >ntry dec"aration at the top. b# the inc"ude fi"e that defines the re.isters of the MCU c# the A5B dec"aration abo!e the >ntry "abe" and d# the A5B C<<<> and D$.% >ntry dec"aration be"ow the pro.ram. 7"so note that the boo( does not define 7ssemb"y code this way. his is for compatibi"ity with a !ariety of 7ssemb"ers for the &C$1'. $ee the fu"" code defined for Code%arrior be"ow the .raphic. /ou can use the code as temp"ate for e1amp"es in the boo( by rep"acin. the code between >ntry: and >)D.

If this is confusing, you can delete everything in the main.asm program in the CodeWarrior. Then go to the www.MicroDigitalEd.com web site and under C!"# boo$ clic$ on %Dragon"# !ample &rograms and !upport'. (ou will see sample programs in both )ssembly and C for Dragon"# plus Trainer board. In the )ssembly program section Clic$ on %Toggling *EDs on &+,T-'. Copy the program and paste it into the main.asm program. 8# <u"" Chip $imu"ation shou"d be se"ected in the drop down bo10 C"ic( Ma(e icon 3<7# C"ic( Debu. 3<9#. $ee the Debu. utoria" for detai"s.

D# 7fter c"ic(in. <9 3Debu.# Code%arrior wi"" .i!e you 4 rue ime $imu"ator E 5ea" ime Debu..er6 screen. Use <11 to sin."e step throu.h the pro.ram or use b"ue icons to debu. the pro.ram. o e1amine the contents of memory "ocations c"ic( on Memory window and you wi"" see Memory at the top 3 ne1t to Component#. C"ic( on Memory and drop-down menu .i!es you the options. $ee the Debu. utoria" for detai"s.

"./ Compiling, Downloading and E0ecuting a pro.ram for Dra.on1' *"us rainer board 3or any trainer board#. )ow0 c"ose the rue- ime $imu"ation window. De"ete e!erythin. in the main.asm pro.ram in the Code%arrior. Bo to the www.MicroDi.ita">d.com web site and under &C$1' boo( c"ic( on 4Dra.on1' $amp"e *ro.rams and $upport6. /ou wi"" see samp"e pro.rams in both 7ssemb"y and C for Dra.on1' p"us rainer board. -n the 7ssemb"y pro.ram section C"ic( on 4 o.."in. F>Ds on *A5 @6. Copy the pro.ram and paste it into the main.asm pro.ram 11# -n the drop-down where it shows <u"" Chip $imu"ation choose C!"# !erial Monitor. Connect your Dra.on1' board to the 18= *C U$@ port and power up the board. *ress the 5>$> button. hen *ress <7 3ma(e#0 <9 3Debu.# to Down"oad 3ma(e sure you choose the ri.ht CAM port#0 and <9 3run# to e1ecute the pro.ram. /ou wi"" see the F>Ds to.."e on and off.

"#/ )lways close the True1time !imulation window, ,E!ET the board, and ma$e sure you are in C!"# !erial Monitor mode before you download and e0ecute any program.

Vous aimerez peut-être aussi