所需E币: 4
时间: 2019-12-24 19:09
大小: 247.84KB
Traditionally,themicrocontrollerstackhasonlybeenusedasastoragespaceforreturnaddressesofsub-routinesorinterruptroutines,whereall‘push’and‘pop’operationswerehidden.Forthemostpart,usershadnodirectaccesstotheinformationonthestack.ThePIC18microcontrollerdivergesfromthistraditionslightly.WiththenewPIC18core,usersnowhaveaccesstothestackandcanmodifythestackpointerandstackdatadirectly.Havingsuchlevelsofaccesstothestackallowsforsomeuniqueandinterestingprogrammingpossibilities.Thisapplicationnotedescribesspecificinformation,registers,andinstructionsrelatedtoaccessingthestack.Anexampleisalsoincludeddemonstratingaverysimpletaskmanager,anessentialelementforareal-timeoperatingsystem(RTOS).MAN818ManipulatingtheStackofthePIC18MicrocontrollerAuthor:RossM.FoslerThepointertothetopofthestackisprovidedinregisterMicrochipTechnologyInc.STKPTR.Thepointerisonlyfive-bitswide,whichaccountsforastackdepthof32words.However,thefirstlocationisnotcounted,sinceitisnotphysicallyaINTRODUCTIONmemorylocationinthestack.ThefirstlocationalwaysTraditionally,themicrocontrollers……