I2CINIT
Line 28: | Line 28: | ||
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. | 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. | ||
+ | |||
+ | |||
+ | |||
+ | For normal AVR processors with multiple TWI interfaces you can specify the interface : TWI or TWI1. | ||
+ | |||
+ | When no parameter is provided, the first default TWI will be selected. | ||
| |
Revision as of 20:55, 17 January 2017
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.
For normal AVR processors with multiple TWI interfaces you can specify the interface : TWI or TWI1.
When no parameter is provided, the first default TWI will be selected.
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 |
---|