I2CINIT
(Difference between revisions)
(Created page with "= <span class="f_Header">Action</span> = Initializes the SCL and SDA pins. <span style="font-family: Arial;"> </span> <span style="font-family: Arial;"> </span> ...") |
|||
Line 51: | Line 51: | ||
= <span class="f_Header">Example</span> = | = <span class="f_Header">Example</span> = | ||
− | + | <br/><source lang="bascomavr"> | |
Config Sda = Portb.5 | Config Sda = Portb.5 | ||
Config Scl = Portb.7 | Config Scl = Portb.7 | ||
Line 61: | Line 61: | ||
I2creceive Slave , X 'get the value | I2creceive Slave , X 'get the value | ||
Print X 'print it | Print X 'print it | ||
− | </source><br/><span | + | </source><br/> |
+ | = <span class="f_Header">Example XMEGA</span> = | ||
<br/><source lang="bascomavr"> | <br/><source lang="bascomavr"> |
Revision as of 20:22, 11 February 2013
Contents |
Action
Initializes the SCL and SDA pins.
Syntax
I2CINIT
I2CINIT #const
Remarks
By default the SCL and SDA pins are in the right state when you reset the chip. Both the PORT and the DDR bits are set to 0 in that case.
When you need to change the DDR and/or PORT bits you can use I2CINIT to bring the pins in the proper state again.
For the XMEGA which has multiple TWI interfaces you can use a channel to specify the TWI interface otherwise the default TWIC will be used.
ASM
The I2C routines are located in i2c.lib. _i2c_init is called.
See also
I2CSEND , I2CSTART , I2CSTOP , I2CRBYTE , I2CWBYTE , I2C_TWI Library for using TWI
Example
Config Sda = Portb.5 Config Scl = Portb.7 I2cinit Dim X As Byte , Slave As Byte X = 0 'reset variable Slave = &H40 'slave address of a PCF 8574 I/O IC I2creceive Slave , X 'get the value Print X 'print it
Example XMEGA
Open "twic" For Binary As #4 ' or use TWID,TWIE oR TWIF Config TwiC = 100000 'CONFIG TWI will ENABLE the TWI master interface I2cinit #4
Languages | English • Deutsch |
---|