Joyhtidas
Member level 4
- Joined
- Nov 30, 2009
- Messages
- 72
- Helped
- 4
- Reputation
- 8
- Reaction score
- 1
- Trophy points
- 1,288
- Location
- Bangalore, India
- Activity points
- 1,709
Hai.. i am using PIC24F controller and SAA1064 for driving the seven segment display. Here i am facing the problem is that, the address of the IC 0x70 is Acknowledging.. but remaining things are not( I am checking with the Oscilloscope)... Friends Pls give me a solution
Thanx in advance..
the code is given below..
#include <p24fj128ga010.h>
#include <timer.h>
#include <i2c.h>
#define I2C_BRG 19 // Setting baud rate as 100KHz
/****** I2C_ic_Initialization ****/
void I2C_ic_Init()
{
//Enable channel
OpenI2C1( I2C_ON, I2C_BRG );
}
/***** Checking the Acknowledge ***/
void Ack_chk()
{
I2C1STATbits.ACKSTAT=0;
//ACKSTAT is 0 when slave acknowledge,
//if 1 then slave has not acknowledge the data.
while(I2C1STATbits.ACKSTAT);
I2C1STATbits.ACKSTAT=0;
}
/****** Main function *****/
int main(void)
{
I2C_ic_Init();
StartI2C1();
IdleI2C1();
MasterWriteI2C1(0x70);
IdleI2C1();
Ack_chk();
MasterWriteI2C1(0x00);
IdleI2C1();
Ack_chk();
MasterWriteI2C1(0x46);
IdleI2C1();
Ack_chk();
MasterWriteI2C1(0xFF);
IdleI2C1();
Ack_chk();
MasterWriteI2C1(0xFF);
IdleI2C1();
Ack_chk();
MasterWriteI2C1(0x00);
IdleI2C1();
Ack_chk();
MasterWriteI2C1(0x00);
IdleI2C1();
Ack_chk();
StopI2C1();
return 0;
}
Thanx in advance..
the code is given below..
#include <p24fj128ga010.h>
#include <timer.h>
#include <i2c.h>
#define I2C_BRG 19 // Setting baud rate as 100KHz
/****** I2C_ic_Initialization ****/
void I2C_ic_Init()
{
//Enable channel
OpenI2C1( I2C_ON, I2C_BRG );
}
/***** Checking the Acknowledge ***/
void Ack_chk()
{
I2C1STATbits.ACKSTAT=0;
//ACKSTAT is 0 when slave acknowledge,
//if 1 then slave has not acknowledge the data.
while(I2C1STATbits.ACKSTAT);
I2C1STATbits.ACKSTAT=0;
}
/****** Main function *****/
int main(void)
{
I2C_ic_Init();
StartI2C1();
IdleI2C1();
MasterWriteI2C1(0x70);
IdleI2C1();
Ack_chk();
MasterWriteI2C1(0x00);
IdleI2C1();
Ack_chk();
MasterWriteI2C1(0x46);
IdleI2C1();
Ack_chk();
MasterWriteI2C1(0xFF);
IdleI2C1();
Ack_chk();
MasterWriteI2C1(0xFF);
IdleI2C1();
Ack_chk();
MasterWriteI2C1(0x00);
IdleI2C1();
Ack_chk();
MasterWriteI2C1(0x00);
IdleI2C1();
Ack_chk();
StopI2C1();
return 0;
}