Rev. 1.20 112 January 23, 2015 Rev. 1.20 113 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
TheIICDregisterisusedtostorethedatabeingtransmittedandreceived.Beforethedevicewrites
datatotheI
2
Cbus,theactualdatatobetransmittedmustbeplacedintheIICDregister.Afterthe
dataisreceivedfromtheI
2
Cbus,thedevicecanreaditfromtheIICDregister.Anytransmissionor
receptionofdatafromtheI
2
CbusmustbemadeviatheIICDregister.
IICD Register
Bit 7 6 5 4 3 2 1 0
Name IICD7 IICD6 IIC
D5 IICD4 IICD3 IICD2 IICD1 IICD0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
POR x x x x x x x x
"x
" unknown
IICA Register
Bit 7 6 5 4 3 2 1 0
Name IICA6 IICA
5 IICA4 IICA3 IICA2 IICA1 IICA0 —
R/W R/W R/W R/W R/W R/W R/W R/W —
POR 0 0 0 0 0 0 0 —
Bit7~1 IICA6~IICA0:I
2
Cslaveaddress
IICA6~IICA0istheI
2
Cslaveaddressbit6~bit0.
TheIICAregisteristhelocationwherethe7-bitslaveaddressoftheslavedevice
isstored.Bits7~1oftheIICAregisterdenethedeviceslaveaddress.Bit0isnot
dened.
Whenamasterdevice,whichisconnectedtotheI
2
Cbus,sendsoutanaddress,which
matchestheslaveaddressintheIICAregister,theslavedevicewillbeselected.
Bit0 Unimplemented,readas"0"
I
2
C Bus Communication
CommunicationontheI
2
Cbusrequiresfourseparatesteps,aSTARTsignal,aslavedeviceaddress
transmission,adatatransmissionandfinallyaSTOPsignal.WhenaSTARTsignalisplacedon
theI
2
Cbus,alldevicesonthebuswillreceivethissignalandbenotiedoftheimminentarrivalof
dataonthebus.Therstsevenbitsofthedatawillbetheslaveaddresswiththerstbitbeingthe
MSB.Iftheaddressoftheslavedevicematchesthatofthetransmittedaddress,theIICHAASbit
intheIICC1registerwillbesetandanI
2
Cinterruptwillbegenerated.Afterenteringtheinterrupt
serviceroutine,theslavedevicemustfirstchecktheconditionoftheIICHAASandI2CTOF
bitstodeterminewhethertheinterruptsourceoriginatesfromanaddressmatchorfromanI
2
C
communicationtime-outorfromthecompletionofan8-bitdatatransfer.Duringadatatransfer,note
thatafterthe7-bitslaveaddresshasbeentransmitted,thefollowingbit,whichisthe8thbit,isthe
read/writebitwhosevaluewillbeplacedintheIICSRWbit.Thisbitwillbecheckedbytheslave
devicetodeterminewhethertogointotransmitorreceivemode.Beforeanytransferofdatatoor
fromtheI
2
Cbus,themicrocontrollermustinitialisethebus,thefollowingarestepstoachievethis:
• Step1
SettheIICENbitintheIICC0registerhightoenabletheI
2
Cbus.
• Step2
WritetheslaveaddressofthedevicetotheI
2
CbusaddressregisterIICA.
• Step3
SettheIICEinterruptenablebitoftheinterruptcontrolregistertoenabletheI
2
Cinterrupt.