| Electronic Components Datasheet Search |
|
SN8F5708 Datasheet(PDF) 162 Page - SONiX Technology Company |
|
|
|||||||||||||||||||||||||||||
SN8F5708 Datasheet(HTML) 162 Page - SONiX Technology Company |
|
162 / 204 page ![]() www.sonix.com.tw SN8F5708 Series Copyright © 2019, SONiX Technology Co., Ltd. I2C Datasheet Rev. 2.4 162 22.8 Sample Code The following sample code demonstrates how to perform I2C with interrupt. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 unsigned int I2CAddr; unsigned int I2C_TXData0; unsigned int I2C_TXDatan; unsigned int I2C_RXData0; unsigned int I2C_RXDatan; void I2CInit(void) { P1M &= 0xCF; // P14 & P15 as input // configure I2C clock(T1)and enable I2C. I2CCON |= 0xC3; TMOD = 0x60; // auto reload TCON0 = 0x07; // Fosc/1 TH1 = 0xF6; //400kHz TL1 = 0xF6; //400kHz or TH1 = 0xD8; //100kHz TL1 = 0xD8; //100kHz TR1 = 1; // enable I2C interrupt EI2C = 1; //enable global interrupt EAL = 1; I2CCON |= 0x20; // START (STA) = 1 } void I2cInterrupt(void) interrupt ISRI2c //0x43 { switch (I2CSTA) { // tx mode case 0x08: I2CCON &= 0xDF; // START (STA) = 0 I2CDAT = I2CAddr; // Tx/Rx addr break; case 0x18: // write first byte I2CDAT = I2C_TXData0; break; case 0x28: // write n byte I2CDAT = I2C_TXDatan; break; case 0x30: // STOP (STO) I2CCON |= 0x10; break; // rx mode case 0x40: // get slave addr I2CCON |= 0x04; // AA = 1 break; case 0x50: // read n byte I2C_RXData0 = I2CDAT; I2CCON &= 0xFB; // AA = 0 break; |
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |