![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
dais
Joined: 03 May 2004 Posts: 11
|
What happen, when i2c_start fails? |
Posted: Thu Aug 26, 2004 12:10 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 26, 2004 12:56 pm |
|
|
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);
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
dais
Joined: 03 May 2004 Posts: 11
|
|
Posted: Thu Aug 26, 2004 1:17 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
dais
Joined: 03 May 2004 Posts: 11
|
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|