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

What happen, when i2c_start fails?

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



Joined: 03 May 2004
Posts: 11

View user's profile Send private message

What happen, when i2c_start fails?
PostPosted: Thu Aug 26, 2004 12:10 pm     Reply with quote

Hi,

I am testing i2c when I don't supply power. code as follows:


Code:

    #include<16F877A.H>
#fuses HS, NOWDT, PUT, NOBROWNOUT, NOLVP, NOWRT
#use delay(clock = 20000000)
#use i2c(Master, sda=PIN_C4, scl=PIN_C3, FORCE_HW)
void main()
{
    output_float(PIN_C3);
    output_float(PIN_C4);

     i2c_start();
     output_low(Pin_A0);
   delay_ms(1000);
    output_high(Pin_A0);
 
   
}


Pin A0 connect to LED where power is supplied all time, whenever I turn on power on I2C bus, LED will be on for 1 second. However whenever I turn off I2C bus power, it looks like i2c_start() waiting for I2C bus power for ever, it never come to "output_low(Pin_A0), Is there anyway I could setting a timeout, to force I2C_Start() stop?

Thanks in advance

Simin
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Aug 26, 2004 12:56 pm     Reply with quote

Make a small test program similar to the one below and compile it.
Set the compiler to produce a symbolic list file.
This can be done in MPLAB 6.xx by clicking on a box in
the project settings. In MPLAB 5.xx, it can be done by
setting the compiler options to +LY.

Then study the .LST file while reading the data sheet
and you will see what the CCS library code is doing.

If you don't like the CCS code, then you may have to
write your own i2c functions. There is sample code
in the forum archives and on the net to help you do this.

Code:
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#use i2c(Master, sda=PIN_C4, scl=PIN_C3, FORCE_HW)

main()
{
i2c_start();

while(1);
}
 
dais



Joined: 03 May 2004
Posts: 11

View user's profile Send private message

PostPosted: Thu Aug 26, 2004 1:17 pm     Reply with quote

Thanks PCM, I just study assembly code, it looks like it is in infinite loop, unless sth happens, all I can do is to write my own I2c_start function. I search the archives, there are so many topic relate to I2C, I could not find the link that someone post their own I2c code. Is it possible to give me some key words so I could search later on.

Thank you so much

Simin
dais



Joined: 03 May 2004
Posts: 11

View user's profile Send private message

PostPosted: Thu Aug 26, 2004 1:32 pm     Reply with quote

Never mind, I find link :
http://web.ukonline.co.uk/j.winpenny/pic/msspi.txt

Simin
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Aug 26, 2004 1:42 pm     Reply with quote

Here is a port to CCS, that I did for that code:
http://www.ccsinfo.com/wwwboard/messages/725.html
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