I2C issues dsPIC33EP

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
Lord Grezington
Flowcode V4 User
Posts: 288
Joined: Wed Nov 02, 2011 11:15 pm
Has thanked: 29 times
Been thanked: 30 times
Contact:

I2C issues dsPIC33EP

Post by Lord Grezington »

Hello Everyone

I am hoping this is just a quick little issue...

I am using a dsPIC33EPMC204 on a PCB. I need to get the I2C working for a temperature sensor (SA56004ADP). I wanted to use Hardware channel 1 as I need the smBUS feature on the pins B9 & B8. At first nothing happened, but then I went into project options and changed the I2C to alternate pins.

This now only half works as the traces look as though they were charging a capacitor... (I have attached the trace I get similar traces with CLK and DAT) then eventually it would stop working.

I thought that perhaps the PCB was maybe giving high capacitance, but when I toggled the B9 pin on/off with 1us delays it worked fine with no saw tooth look. Also it did not stop working.

Is there a setting somewhere I need to change in order to get the I2C working as expected?

thanks

Thanks
I2C issue.png
(49.88 KiB) Downloaded 3020 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: I2C issues dsPIC33EP

Post by QMESAR »

Hi.

Just a stupid question do you have Pull up resistors on the I2C lines ?

Lord Grezington
Flowcode V4 User
Posts: 288
Joined: Wed Nov 02, 2011 11:15 pm
Has thanked: 29 times
Been thanked: 30 times
Contact:

Re: I2C issues dsPIC33EP

Post by Lord Grezington »

Sorry, should have said. Yes, there are 10K pullups on both clock and data lines.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: I2C issues dsPIC33EP

Post by QMESAR »

Hi.

I asked because I had a similar issue with 10K resistors on a dsPIC30Fxxx MCxxx device with 400Khz baud rate , I reduced them to 4.7K an it worked .
not saying it is the issue but could be

Good luck :D

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: I2C issues dsPIC33EP

Post by Benj »

I agree with QMESAR it looks like your pull up resistor values might be too high.

1K - 4K7 pull ups should work a lot better or try at a slower speed.

Lord Grezington
Flowcode V4 User
Posts: 288
Joined: Wed Nov 02, 2011 11:15 pm
Has thanked: 29 times
Been thanked: 30 times
Contact:

Re: I2C issues dsPIC33EP

Post by Lord Grezington »

Ok, I will give it a go... thanks

Lord Grezington
Flowcode V4 User
Posts: 288
Joined: Wed Nov 02, 2011 11:15 pm
Has thanked: 29 times
Been thanked: 30 times
Contact:

Re: I2C issues dsPIC33EP

Post by Lord Grezington »

Hello QMESAR & Ben

I need a little more help with the protocol if possible. To read a register this is what is said:
I2C issue 1.png
(115.26 KiB) Downloaded 3002 times
My slave address is 0x90, so I use the following code:
I2C issue 4.png
(131.57 KiB) Downloaded 3000 times
I2C issue 3.png
(140.94 KiB) Downloaded 3002 times
EDIT: - This is the correct trace - the serial decoding must be wrong somewhere as the address is wrong. but if you follow the clock/data it correct.

But I am getting 0xFF returned, can you see what is going wrong with it?

Thanks

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: I2C issues dsPIC33EP

Post by QMESAR »

Hi,
It is hard to say from only the schematic of the device communication protocol ,however in general
I2C is very particular with the whole sequence that it needs with that said I mean it would be nice if your pico decoder could show the start bit the restart bit and the acknowledge from(my logic analyser has the option to set these bits a different color that a person can see them in the trace) the device and from your master because you then need to check if the sequence and the data you send between the start's and the acknowledges are correct

If the start and acknowledges does not happen in the correct order you will see all sorts garbage unfortunately I never used the FC I2C components I use plain C code
Ben will help you certainly out here

Good luck :D

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: I2C issues dsPIC33EP

Post by LeighM »

Hi,
I think the problem could be your TransmitByte(Address)
The device address is 7 bits, the most significant bits, and the least significant bit 0 indicates write or read,
So the first TransmitByte(Address) should be TransmitByte(Address << 1) where bit 0 = 0 to indicate a write transaction,
and second TransmitByte(Address) should be TransmitByte((Address << 1)+1) where bit 0 = 1 to indicate a read transaction.
Hope that helps,
Leigh

Lord Grezington
Flowcode V4 User
Posts: 288
Joined: Wed Nov 02, 2011 11:15 pm
Has thanked: 29 times
Been thanked: 30 times
Contact:

Re: I2C issues dsPIC33EP

Post by Lord Grezington »

Hello All

The addressing issue I have now got sorted out, but i think there is something fishy with the I2C.

I have tried both software and hardware modes, I have done a customer baud down to 10K/sec and the MC is freezing. When on the hardware mode I get only one data stream and then it stops, when I change it to software mode I get nothing.

I have tried a different temperature sensor on a different PCB with using dsPIC33EP32MC504 rather than the dsPIC33EP32MC204 and a temperature sensor EMC1412-1-ACZL-TR and it works beautifully. Again the thing that is baffling me is that I can toggle the same IO pin high/low with 1us delays and there is not problem. As though the problem is with the i2C component.

Thanks

Post Reply