InNeedOfHelp
Full Member level 3
- Joined
- Dec 5, 2012
- Messages
- 169
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 1,298
- Activity points
- 2,205
IdleI2C(); // ensure module is idle
StartI2C(); // initiate START condition
#include <i2c.h>
#include i2c.h
those with I2c are included in the header fileCode:#include i2c.h
TRIS A = 0XFF;
TRISB = 0X01;
TRISC=0XBB;
TRISD=0X00;
TRISE=0XFF;
LATA =0X00;
LATB=0X00;
LATC=0X80;
#define TC74_READ 0x9B
#define TC74_WRITE 0x9A
//////////////////////////////////////////////////////////////
void tc74_write(unsigned char reg,unsigned char val)
{
i2c_start();
i2c_write(TC74_WRITE);
i2c_write(reg);
i2c_write(val);
i2c_stop();
}
//////////////////////////////////////////////////////////////
void tc74_read(unsigned char reg,unsigned char *value)
{
i2c_start();
i2c_write(TC74_WRITE);
i2c_write(reg);
i2c_repStart();
i2c_write(TC74_READ);
*value=i2c_read(0); //ACK
i2c_stop();
}
START|TC74_WRITE|ACK|reg|ACK|repstart|TC74_READ|AC K|read data|NACK|STOP
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?