English
Language : 

UPSD33XX Datasheet, PDF (108/231 Pages) STMicroelectronics – Fast 8032 MCU with Programmable Logic
uPSD33xx
I2C Operating Sequences
The following pseudo-code explains hardware
control for these I2C functions on the uPSD33xx:
– Initialize the Interface
– Function as Master-Transmitter
– Function as Master-Receiver
– Function as Slave-Transmitter
– Function as Slave-Receiver
– Interrupt Service Routine
Full C code drivers for the uPSD33xx I2C inter-
face, and other interfaces are available from the
web at www.st.com\psm.
Initialization after a uPSD33xx reset
Ensure pins P3.6 and P3.7 are GPIO in-
puts
– SFR P3.7 = 1 and SFR P3.6 = 1
Configure pins P3.6 and P3.7 as I2C
– SFR P3SFS.6 = 1 and P3SFS.7 = 1
Set I2C clock prescaler to determine
fSCL
– SFR S1CON.CR[2:0] = desired SCL
freq.
Set bus START condition sampling
– SFR S1SETUP[7:0] = number of sam-
ples
Enable individual I2C interrupt and
set priority
– SFR IEA.I2C = 1
– SFR IPA.I2C = 1 if high priority is
desired
Set the Device address for Slave mode
– SFR S1ADR = XXh, desired address
Enable SIOE (as Slave) to return an
ACK signal
– SFR S1CON.AA = 1
Master-Transmitter
Disable all interrupts
– SFR IE.EA = 0
Set pointer to global data xmit buff-
er, set count
– *xmit_buf = *pointer to data
– buf_length = number of bytes to
xmit
Set global variables to indicate Mas-
ter-Xmitter
– I2C_master = 1, I2C_xmitter = 1
Disable Master from returning an ACK
– SFR S1CON.AA = 0
Enable I2C SIOE
– SFR S1CON.INI1 = 1
Transmit Address and R/W bit = 0 to
Slave
– Is bus not busy? (SFR S1STA.BBUSY
= 0?)
<If busy, then test until not busy>
– SFR S1DAT[7:0] = Load Slave Ad-
dress & FEh
– SFR S1CON.STA = 1, send START on
bus
<bus transmission begins>
Enable All Interrupts and go do some-
thing else
– SFR IE.EA = 1
Master-Receiver
Disable all interrupts
– SFR IE.EA = 0
Set pointer to global data recv buff-
er, set count
– *recv_buf = *pointer to data
– buf_length = number of bytes to
recv
Set global variables to indicate Mas-
ter-Xmitter
– I2C_master = 1, I2C_xmitter = 0
Disable Master from returning an ACK
– SFR S1CON.AA = 0
Enable I2C SIOE
– SFR S1CON.INI1 = 1
Transmit Address and R/W bit = 1 to
Slave
– Is bus not busy? (SFR S1STA.BBUSY
= 0?)
<If busy, then test until not busy>
– SFR S1DAT[7:0] = Load Slave Ad-
dress # 01h
– SFR S1CON.STA = 1, send START on
bus
<bus transmission begins>
Enable All Interrupts and go do some-
thing else
– SFR IE.EA = 1
108/231