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

Anyone using I2C nofloat_high option?

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



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

Anyone using I2C nofloat_high option?
PostPosted: Sun Nov 08, 2009 5:19 am     Reply with quote

Hello,

I tried to replace my proprietary software I2C code by CCS built-in I2C function for a PIC16F688. The design is driving SCL in
push-pull style to save power, so I thought, that nofloat_high can provide a similar functionality.
Code:
#use I2C(master,scl=PIN_SCL,sda=PIN_SDA, nofloat_high, slow,force_sw,no_stretch)

This actually works for SCL, but SDA isn't operated any more, e.g. not pulled low in initial i2c_start().

The problem seems to continue from PCM V3.222 until most recent V4.099. Did anyone use nofloat_high successfully with PCM?

Best regards,
Frank

P.S.: I know that there are other posts related to nofloat_high, but none is addressing a problem of I2C not
working at all with PCM when using this feature.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Nov 08, 2009 6:43 am     Reply with quote

The problem seems to be, that the software I2C apparently never touches the TRIS registers when nofloat_high
is specified. If you set SDA initially as output, it's operated as output all the time, no ack or read data is ever seen by the
software I2C. I don't understand what nofloat_high is good for.
Code:
#include   <16F688.h>
#fuses NOWDT,INTRC_IO, NOCPD,   NOPROTECT, PUT, MCLR,   NOBROWNOUT, NOIESO,   NOFCMEN
#use delay(clock=8000000)
#define PIN_SCL PIN_C4
#define PIN_SDA PIN_A5
#use I2C(master,scl=PIN_SCL,sda=PIN_SDA, nofloat_high, slow,force_sw,no_stretch)

void main()
{
 output_high(PIN_SCL);
 output_high(PIN_SDA);

 i2c_start();
 i2c_write(0x90);
 i2c_write(1);
 i2c_write(0xff);
 i2c_stop();
 while (1);
}
Ttelmah
Guest







PostPosted: Sun Nov 08, 2009 11:18 am     Reply with quote

There won't be much power reduction, using NO_FLOAT_HIGH anyway. The resistors on the I2C lines only draw power, when the lines are being driven low. 99% of the time, they draw nothing. The code generated by NO_FLOAT_HIGH, does not show this as an option in place of using the resistors, but an option designed to speed up the rising edge transistion. The code only seems to work for software I2C, and momentarily applies an output high, when the line is meant to drive high, switching almost immediately to letting the line float. The lines _must_ float, otherwise I2C won't work. Remember that a slave device can hold the clock line low, to signal that it is not yet finished. Driving the line permanently high would prevent this. Similarly on the data line, it must be released or a slave device can't write, and unless the slave device was also driving the lines high (and therefore potentially clashing), it will need the resistors to pull the lines high.
NO_FLOAT_HIGH, seems to be an attempt to similuate in software the action of some of the active line terminators, potentially giving faster rising edges, with larger terminating resistors. However terminating resistors are still needed, and I have not seen any examples of this actually working....

Best Wishes
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Nov 09, 2009 12:03 am     Reply with quote

Thanks for responding,

I remember to have seen nofloat_high operating in the way you described with PCH. But with PCM, I don't see it working at all. That's why I asked, if anyone is using it.

I went back to my own I2C code, that has no problems, except not being as size optimzed as the CCS built-in routines. The product uses a very small PIC and I hoped to save a few percent of ROM. I can do my own asm code, if the ROM space is actually exhausted.

Best regards,
Frank
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