Micrcontroller Programming Using C With Keil IDE
Micrcontroller Programming Using C With Keil IDE
MicrcontrollerProgrammingUsingC March25,2011
WithKeilIDE
KEILuVisionisthenameofasoftwarededicatedtothedevelopmentandtestingofa
familyofmicrocontrollersbasedon8051technology,whichwearegoingtousealongthis
tutorial.YoucancandownloadanevaluationversionofKEILattheir
website:http://www.keil.com/c51/.Mostversionssharemerelythesameinterface,this
tutorialusesKEILC51uVision4withtheC51compiler.
Tocreateproject,writeandtestthesourcecodeandalsocreatehexfile,followthe
followingsteps:
OpenKeilandStartanewproject:
Youwillpromptedtochoseanameforyournewproject,choseanameand
clicksave.Thefollowingwindowwillappear,whereyouwillbeaskedtoselectadevicefor
TargetTarget1:
Fromthelist,selectATMELandchoseyourmicrocntroller.TheAT89s52willbecalled
yourTargetdevice,whichisthefinaldestinationofyoursourcecode.Youwillbeasked
https://vshamu.wordpress.com/2011/03/25/micrcontrollerprogrammingusingcwithkeilide/ 1/2
3/19/2017 MicrcontrollerProgrammingUsingCWithKeilIDE|
whethertocopystandard8051startupcodeclickNo.
ClickFile,Newandsimilartothefollowingwindowshouldappear.Theblankspacewhere
yourcodeshouldbewritten.
Now,YouhavetoclickFile,Saveasandchoseafilenameforcodeendingwiththe
extension.candclicksave.Thenyouhavetoaddthisfiletoyourprojectworkspaceas
showninthefollowingscreen:
Afterrightclickingonsourcegroup1,clickonAddfilestogroup,thenyouwillbe
promptedtobrowsethefiletoaddtosourcegroup1,chosethefilethatyoujustsaved
andaddittothesourcegroup.Youwillnoticethatthefileisaddedtotheprojecttreeat
theleft.
InsomeversionsofthissoftwareyouhavetoturnONmanuallytheoptiontogenerate
HEXfiles.makesureitisturnedON,byrightclickingontarget1,Optionsfortarget
target1,thenundertheoutputtab,bycheckingtheboxgenerateHEXfile.Thisstep
isveryimportantastheHEXfileisthecompiledoutputofyourprojectthatisgoingtobe
transferredtothemicrocontroller.
Youcanthenstarttowritethesourcecodeinthewindowthenbeforetestingyoursource
code,youhavetocompileyoursourcecode,andcorrecteventualsyntaxerrors.InKEIL
IDE,thisstepiscalledrebuildalltargets.
https://vshamu.wordpress.com/2011/03/25/micrcontrollerprogrammingusingcwithkeilide/ 2/2