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 CCS Technical Support

Help for the I2C communication!

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 19, 2006 1:16 pm     Reply with quote

Quote:
I don't know how to change the clk freq for I2C mode.

You can do it like this:
Code:
#use i2c(Master, SDA=PIN_C4, SCL=PIN_C3, FORCE_HW, FAST=300000)

Specify FORCE_HW, and then specify the i2c clock speed with the
FAST statement. In the example above, I have specified 300 KHz.

If you use "FAST" with no speed parameter, it defaults to 400 KHz.
Example:
Code:
#use i2c(Master, SDA=PIN_C4, SCL=PIN_C3, FORCE_HW, FAST)


However, you think that changing the i2c clock speed from 100 KHz
to 400 KHz will magically fix the problem with reading FF's. I don't
think that's going to happen. It could be that there's a problem in
my driver (since I don't have a hardware chip to test), but I think
there is likely a problem in your hardware connections.
jds-pic



Joined: 17 Sep 2003
Posts: 205

View user's profile Send private message

PostPosted: Tue Dec 19, 2006 1:18 pm     Reply with quote

Kyaw Kyaw wrote:
Hi,
Could you please show me how to set the clk freq for communication? I don't know how to change the clk freq for I2C mode.


the i2c bus normally runs at either 100KHz (STD mode) or 400KHz (FAST mode).

within CCS you don't explicitly set a clock frequency; the i2c driver defaults to STD unless you specify FAST in the #use_i2c directive.

do you have a 'scope that you can put onto SCL and SDA to see if ANY data is going back and forth between the PIC and the client IC?

jds-pic
Ttelmah
Guest







PostPosted: Tue Dec 19, 2006 4:07 pm     Reply with quote

First check that you are usig the right address. PCM_programmer, has the right address. The address is 0x44, with then the read/write bit added below this, so it ends up being multiplied by two for sending to the chip.
Your code would not work, if the address was right, since you never set the chip to return data.
PCM_programmers functions look right. Try using the command write function to set the mode you want, and then his read function.

Best Wishes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 19, 2006 4:45 pm     Reply with quote

I'm assuming that he only wants to read the two diodes, so I have
the code to send the command, placed within the "read diodes" function.

I'm not sure what the state of the ISL29001 chip is, upon power-up.
It's possible that it comes up in the "power down" state. The data sheet
isn't clear on this. It might be that you have to send the "Reset"
command to remove the "power down" state, before you can talk to
the chip with i2c.

Also, the schematic on page 10 of the data sheet shows that you have
to connect the Power Down pin to ground. (The chip can be put in
a power-down state either by a software command or a hardware pin).
If any of those pins are not connected correctly, the result might be
to read all FF's back.
http://www.intersil.com/data/fn/FN6166.pdf
Kyaw Kyaw



Joined: 17 Dec 2006
Posts: 15
Location: Singapore

View user's profile Send private message AIM Address MSN Messenger

Thank for ur supports
PostPosted: Tue Dec 19, 2006 7:31 pm     Reply with quote

Hi all,
Thanks for ur supports. But now i try to run with PWM Programmer's code and i made all the setting correctly according to the schematic shown in the ISL 29001 datasheet. Actually I want is to get the Diode1 Data only because I want the light intensity value for control. Could you please make a check for the timming diagram of ISL 29001 included in page 6 of datasheet? I think we need to make acknowledge after sending the device address (0x44 + Read/Write) and after power down command. Thanks for consideration of my problem.

It may be the fault of my IC ISL 29001 because it is too small and I mounted in socket PCBvia soldering. But I check with the camera to see whether it is connected proprely to the socket PCB or not. I didn't see any fault.

Thanks and Best Regards,
Kyaw Kyaw.
_________________
Thanks and Best Regards,
Kyaw Kyaw.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 19, 2006 8:42 pm     Reply with quote

Quote:

I think we need to make acknowledge after sending the device address
(0x44 + Read/Write) and after power down command.

The slave device (the ISL29001) does an ACK to show the master (PIC)
that it has received the address byte. We don't need to add any code
to handle this.

Quote:
(0x44 + Read/Write)

This part is disturbing. Are you using the code that I posted, with
the address of 0x88, or did you change it to 0x44 ? It must be 0x88
for a write and 0x89 for a read operation.

Quote:
and after power down command

This comment is even more disturbing. Are you sending the ISL29001
a power-down command ? If so, why ?

You should follow the example code that I posted. Don't change the
i2c address. Don't send a power-down command to the ISL29001.

Also, I have a moderate belief that the chip is not connected correctly
or was damaged during soldering.
Kyaw Kyaw



Joined: 17 Dec 2006
Posts: 15
Location: Singapore

View user's profile Send private message AIM Address MSN Messenger

Reply
PostPosted: Tue Dec 19, 2006 9:39 pm     Reply with quote

Hi PWM programmer,
I didn't change anything except the PIN Assignement for RS 232 mode because I used B0 and B5 to communication with computer. The rests are still the same as u made, even the ISL 29001 address (0x88 for read and 0x89 for write) commands. Unfortunately it still show FFFF (hex) for data reading. I also tried to send power down mode (0x8c) after sending the write address command. At that time it didn't show anything even the data value of FFFF(hex) or sample sentence. I also suspect on the IC soldering. This IC is very tiny one and I also try my best to solder it. Do you have any idea for power down mode. Thanks for ur support and considering my problem. Below is the code i tried to test.

#include <16F877A>
#fuses HS, NOWDT, PROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_B0, rcv=PIN_B5)
#use i2c(Master, sda=PIN_C4, scl=PIN_C3, FORCE_HW)


int16 result=0;

VOID main()
{
WHILE(1)
{
prINTf ("\n\rHello World Testing ISL 29001\n\r");

i2c_start();
i2c_write(0x88); // Send the ISL29001 address
i2c_write(0x8c); // send power down signal
i2c_write(0x30); // Set internally timed
i2c_stop();
delay_ms(2500);

i2c_start();
i2c_write(0x89);
result=i2c_read();
i2c_stop();
printf ("\n\r data1 value1 is %x\n\r",result);

delay_ms (1000);

}
}
_________________
Thanks and Best Regards,
Kyaw Kyaw.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 19, 2006 10:30 pm     Reply with quote

You're not following my sample driver. You are inventing stuff.
I give up.
Kyaw Kyaw



Joined: 17 Dec 2006
Posts: 15
Location: Singapore

View user's profile Send private message AIM Address MSN Messenger

hi pwm programmer
PostPosted: Tue Dec 19, 2006 11:20 pm     Reply with quote

i also tried with ur program also. but still cannot get the result. that why i tried to use this program.

thanks & best regards,
kyaw kyaw.
_________________
Thanks and Best Regards,
Kyaw Kyaw.
Kyaw Kyaw



Joined: 17 Dec 2006
Posts: 15
Location: Singapore

View user's profile Send private message AIM Address MSN Messenger

It is IC's fault!
PostPosted: Thu Dec 21, 2006 2:44 am     Reply with quote

Hi all, Today i tried to see the sda and scl pin outputs with scope and i found that it is working according to the timing diagram of ISL 29001 but still got FFFF hex and it was not included the 30 hex for writing to ISL29001. I tested with PWM Programmer's codes. It should be the ISL29001's defect. Thanks for helping me to solving my difficulties. Smile Smile
_________________
Thanks and Best Regards,
Kyaw Kyaw.
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