PIC18微控制器的堆栈操纵

上传:lecture69136 浏览: 10 推荐: 0 文件:pdf 大小:247.84 KB 上传时间:2022-10-23 13:10:30 版权申诉

Traditionally,themicrocontrollerstackhasonlybeen

usedasastoragespaceforreturnaddressesofsub-

routinesorinterruptroutines,whereall‘push’and‘pop’

operationswerehidden.Forthemostpart,usershad

nodirectaccesstotheinformationonthestack.The

PIC18microcontrollerdivergesfromthistradition

slightly.WiththenewPIC18core,usersnowhave

accesstothestackandcanmodifythestackpointer

andstackdatadirectly.Havingsuchlevelsofaccessto

thestackallowsforsomeuniqueandinteresting

programmingpossibilities.

Thisapplicationnotedescribesspecificinformation,

registers,andinstructionsrelatedtoaccessingthe

stack.Anexampleisalsoincludeddemonstratinga

verysimpletaskmanager,anessentialelementfora

real-timeoperatingsystem(RTOS).MAN818ManipulatingtheStackofthePIC18MicrocontrollerAuthor:RossM.FoslerThepointertothetopofthestackisprovidedinregisterMicrochipTechnologyInc.STKPTR.Thepointerisonlyfive-bitswide,whichaccountsforastackdepthof32words.However,thefirstlocationisnotcounted,sinceitisnotphysicallyaINTRODUCTIONmemorylocationinthestack.ThefirstlocationalwaysTraditionally,themicrocontrollers

上传资源
用户评论