Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

"PIC24F and SAA1064" interfacing

Status
Not open for further replies.

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;

}
 

I'm not sure, if SAA1064 supports fast I2C as set in your application. You may want to try with safe 100 kHz first.
Also the 5V supply voltage most likely requires I2C pull-up resistors to 5V for reliable high levels at the bus.
 

    Joyhtidas

    Points: 2
    Helpful Answer Positive Rating
ThankX for the reply...
I am using the 4.7K pull up resistors for the I2C..
And I am getting the voltage levels nearly same...
The Baud rate set by me is 100KHz ( BRG 19 = 100KHz)...
Any other points I need to check..?
 

I didn't expect a CPU clock (FCY) of 2 MHz, is it real?
 

Hi...
The Fcy is 4MHz... I checked with the I2C family refernce manual of PIC24F.
What is the BRG value you feel that I need to give..?
Thanx alot for the reply...
 

About doubled. There's a formula in the manual. It's no problem to set the BRG value too high, just to check if the problem is related to I2C speed.
 

I got it worked...


I reduced the Baud rate...(FCY=2MHz)
... and put one capacitor of 0.01µF capacitor between SCL and SDA pins and ground..

ThankX alot dear ...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top