CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

i2c hangup

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pmuldoon



Joined: 26 Sep 2003
Posts: 218
Location: Northern Indiana

View user's profile Send private message

i2c hangup
PostPosted: Fri Aug 25, 2017 8:26 am     Reply with quote

I have a pic that has an i2c Master connection to a single i2c slave chip on a separate pcb. It has been working fine. But if I disconnect the i2c the program hangs. I don't understand from the manual & datasheet why that would happen. The PIC is a Master and it should just toggle the lines and return the ACK status without hanging. Am I missing something obvious here?

Here are my #use setups.
I added some i2c lines below to the beginning of my code and it hangs it up every time. Using either the read or write command causes the hang. I'm going to break out the scope and see what the lines are actually doing. Maybe that will give me a clue.

PIC: 18F67K40
CCS: V5.074
MPLAB X v3.65
setup:
Code:

    #use RS232(UART1,Baud=19200,PARITY=N,BITS=8,ERRORS)
    #use i2c(I2C2, master,FAST=200000)

    // test if I2C lines are floating and not tied to gnd
    if((input(i2c_SDA2) == 0) || (input(i2c_SCK2) == 0)){
       printf("\r\n FAULT: I2C bus line held low!  press any key...");
       getch();
    } else{
       printf("\r\n I2C bus lines floating hi - okay");   
    }
    i2c_start();
    //i2c_read();
    i2c_write(0xa0);
    i2c_stop();
    printf("\r\n Never prints this line");   
Ttelmah



Joined: 11 Mar 2010
Posts: 19436

View user's profile Send private message

PostPosted: Fri Aug 25, 2017 8:49 am     Reply with quote

Look at PCM_programmers I2C bus scanner program in the code library.
This shows how to scan a bus and see if a device is there.

Must admit from what you post, it should reach the print line. Are you sure your line definitions are right?. What is attached?. If your device holds the clock line low when addressed, this would cause a problem....
pmuldoon



Joined: 26 Sep 2003
Posts: 218
Location: Northern Indiana

View user's profile Send private message

PostPosted: Fri Aug 25, 2017 9:35 am     Reply with quote

My definitions should be okay because it seems to work fine as long as the chip is connected. The problem is when nothing is attached at all - the i2c...arg! I just realized something. It's a customer design and the pullups for the i2c are on the remote board! So the i2c lines are literally floating with nothing connected. I'll bet that's somehow the problem.

Sometimes just explaining the problem to someone helps a lot!
temtronic



Joined: 01 Jul 2010
Posts: 9198
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Aug 25, 2017 10:15 am     Reply with quote

oopsy ! yup, floating I2C lines are a big 'NONO'...
..just don't as HOW I know that.....
bottom line .. the master should have pullups, even jumper selectable if need be.

Jay
pmuldoon



Joined: 26 Sep 2003
Posts: 218
Location: Northern Indiana

View user's profile Send private message

PostPosted: Fri Aug 25, 2017 10:33 am     Reply with quote

Understood.
At least it wasn't MY hardware design. I can always say I'd never had done that, LOL. But I'm sure there will be a rev, so I'll put in a request.

Sorry to have bothered you on such a bonehead thing, but at least you got a good laugh on a Friday!!
Ttelmah



Joined: 11 Mar 2010
Posts: 19436

View user's profile Send private message

PostPosted: Fri Aug 25, 2017 11:54 am     Reply with quote

The key one is the clock line. If this is seen as 'low' after a write, the chip will think the I2C is being held low by the other device.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group