|
UPSD3422_06 Datasheet, PDF (128/293 Pages) STMicroelectronics – Turbo Plus Series Fast Turbo 8032 MCU with USB and Programmable Logic | |||
|
◁ |
I2C interface
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 samples
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 buffer, set count
â *xmit_buf = *pointer to data
â buf_length = number of bytes to xmit
Set global variables to indicate Master-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 Address & FEh
â SFR S1CON.STA = 1, send START on bus
<bus transmission begins>
Enable All Interrupts and go do something else
â SFR IE.EA = 1
Master-Receiver
Disable all interrupts
â SFR IE.EA = 0
Set pointer to global data recv buffer, set count
â *recv_buf = *pointer to data
â buf_length = number of bytes to recv
128/293
uPSD34xx
|
▷ |