Rev. 1.20 28 January 23, 2015 Rev. 1.20 29 January 23, 2015
BS82B12A-3/BS82C16A-3/BS82D20A-3
Touch Key 8-Bit Flash MCU with LED/LCD Driver
BS82B12A-3/BS82C16A-3/BS82D20A-3
Touch Key 8-Bit Flash MCU with LED/LCD Driver
Special Vectors
WithintheProgramMemory,certainlocationsarereservedfortheresetandinterrupts.Thelocation
0000Hisreservedforusebythedeviceresetforprograminitialisation.Afteradeviceresetis
initiated,theprogramwilljumptothislocationandbeginexecution.
Look-up Table
AnylocationwithintheProgramMemorycanbedenedasalook-uptablewhereprogrammerscan
storexeddata.Tousethelook-uptable,thetablepointermustrstbesetupbyplacingtheaddress
ofthelookupdatatoberetrievedinthetablepointerregister,TBLPandTBHP.Theseregisters
denethetotaladdressofthelook-uptable.
Aftersettingupthetablepointerpair,thetabledatacanberetrievedfromtheProgramMemory
usingthe"TABRD[m]"or"TABRDL[m]"instructions respectively.Whentheinstructionis
executed,thelowerordertablebytefromtheProgramMemorywillbetransferredtotheuser
denedDataMemoryregister[m]asspeciedintheinstruction.Thehigherordertabledatabyte
fromtheProgramMemorywillbetransferredtotheTBLHspecialregister.Anyunusedbitsinthis
transferredhigherorderbytewillbereadas"0".
Theaccompanyingdiagramillustratestheaddressingdataowofthelook-uptable.
Register T BLH
User S electe d
Register
TBLP R egis te r
Data
Address
16 b its
Last p age o r
TBHP R egister
Table Program Example
Thefollowingexampleshowshowthetablepointerandtabledataisdenedandretrievedfromthe
microcontroller.ThisexampleusesrawtabledatalocatedintheProgramMemorywhichisstored
thereusingtheORGstatement.ThevalueatthisORGstatementis"0700H"whichreferstothe
startaddressofthelastpagewithinthe2KwordsProgramMemoryoftheBS82B12A-3.Thetable
pointerissetupheretohaveaninitialvalueof"06H".Thiswillensurethattherstdatareadfrom
thedatatablewillbeattheProgramMemoryaddress"0706H"or6locationsafterthestartofthe
lastpage.Notethatthevalueforthetablepointerisreferencedtotherstaddressofthespecic
pageifthe"TABRD[m]"instructionisbeingused.Thehighbyteofthetabledatawhichinthis
caseisequaltozerowillbetransferredtotheTBLHregisterautomaticallywhenthe"TABRD[m]"
instructionisexecuted.
BecausetheTBLHregisterisaread-onlyregisterandcannotberestored,careshouldbetaken
toensureitsprotectionifboththemainroutineandInterruptServiceRoutineusetableread
instructions.Ifusingthetablereadinstructions,theInterruptServiceRoutinesmaychangethe
valueoftheTBLHandsubsequentlycauseerrorsifusedagainbythemainroutine.Asaruleitis
recommendedthatsimultaneoususeofthetablereadinstructionsshouldbeavoided.However,in
situationswheresimultaneoususecannotbeavoided,theinterruptsshouldbedisabledpriortothe
executionofanymainroutinetable-readinstructions.Notethatalltablerelatedinstructionsrequire
twoinstructioncyclestocompletetheiroperation.