InNeedOfHelp
Full Member level 3
Code:
IdleI2C(); // ensure module is idle
StartI2C(); // initiate START condition
Where does this 2 come from? do i need to declare?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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