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.

acknowledge polling with the 877a

Status
Not open for further replies.

Joni Bravo

Newbie level 2
Joined
Jun 28, 2005
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,300
877a+sspif

Hi,

Im am trying to make a program what writes to a 24LC512 eerpom(I2C).

I can write to the I2C eeprom but with a delay now i want to use acknowledge polling so its faster.

this is what i have:

Code:
void I2C_start(void)
{
	SEN = 1;
	while(!SSPIF);
	SSPIF = 0;
}

void I2C_stop(void)
{
	PEN = 1;
	while(!SSPIF);
	SSPIF = 0;
}

void I2C_send(unsigned char data)
{
	SSPBUF = data;
	while(!SSPIF);
	SSPIF = 0;
	
}

void I2C_eeprom_write(unsigned char adress_hi,unsigned char adress_lo,unsigned char data)
{
	SSPIF = 0;
	I2C_start();
	I2C_send(control_byte);
	I2C_send(adress_hi);
	I2C_send(adress_lo);
	I2C_send(data);
	I2C_stop();
	
	//delay_ms(5);         // It works if i use a delay


	//acknowledge polling
	//Wait while EEPROM is writing 
	do
	{
		I2C_start();
                I2C_send(control_byte);
	}while(ACKSTAT);
	
	I2C_stop();

}


When i use a delay instead of the acknowledge polling part it works fine.
The program gets stuck somewhere in the acknowledge polling, so what a i doing wrong??????
 

According to 24LC512 data sheet the master device must generate an extra
clock pulse which is associated with the Acknowledge bit.
How this is implemented in your code ..
Regards,
IanP
 

I am using the hardware SPI fuction of the pic16f877a.

The ninth bit is send automaticly and the ack should be saved in de ACKSTAT bit. If i know when the ACKSTAT bit is actually set and reset i think i can make it work, i could't find this info in the datasheet.

Is ACKSTAT set or reset automaticly or do i have to do it in the software?????????
When is that bit set or reset????????????
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top