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.

Problem with ack in I2C (dspic30F2011 )

Status
Not open for further replies.

Navid T

Full Member level 3
Joined
Jan 21, 2005
Messages
186
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,296
Location
Iran
Activity points
1,385
Hi friends
I write this kind of code to send start bit and address to slave:
Code:
_SEN=1;
while(_SEN);
I2CTRN = 0B11010000;
while(_TRSTAT);

It works but the problem is if slave doesn't send ack it'll always wait for ack for ever, how should i write my code that wait for ack but not always?
Regards
 

Code:
int counter_i2c = 0xFFFF;
while((_TRSTAT == 0) && (counter_i2c != 0))			 
	counter_i2c--;

Obviously you can change the counter_i2c value depending on how long you want to wait.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top