I2C ACK

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

User avatar
Alan_37
Posts: 152
Joined: Sun May 01, 2016 8:36 pm
Has thanked: 53 times
Been thanked: 53 times
Contact:

I2C ACK

Postby Alan_37 » Mon Aug 29, 2016 2:51 pm

Hi

I have this issue when communicating with DS1307 RTC
When receiving ACK after D1 flowcode is outputing this as a NACK (1) insted of 0 .

All other Conditions are Correct only the Ack after D1 is incorrect any ideas what can this be ?

Thanks
Attachments
Logic1.png
(104.14 KiB) Downloaded 1368 times

User avatar
Alan_37
Posts: 152
Joined: Sun May 01, 2016 8:36 pm
Has thanked: 53 times
Been thanked: 53 times
Contact:

Re: I2C ACK

Postby Alan_37 » Mon Aug 29, 2016 11:48 pm

Hi

I am continuing to experiment with the intent to help find the problem
below is a waveform of the I2c Protocol sending the same data only this time the data is not
a Read from device command (or condition ) this time flowcode gets the ACK Correct .

The only difference i can see is that the SDA go High exactly after the ACK is Revived .
Attachments
logic 2.png
(99.36 KiB) Downloaded 1350 times

User avatar
Alan_37
Posts: 152
Joined: Sun May 01, 2016 8:36 pm
Has thanked: 53 times
Been thanked: 53 times
Contact:

Re: I2C ACK

Postby Alan_37 » Tue Aug 30, 2016 12:00 am

Hi

Here is another update the problem seems to be only when receiving ACK after the Read Command
below is the waveform of the i2c when Reading from MCP4725 DAC .

Flowcode Gets the ACK Wrong this time outputing it as logic 1 (NACK) .

Hope this will help to find a solution to this problem as soon as possible .

Thanks
Attachments
Logic 3.png
(113.54 KiB) Downloaded 1350 times

User avatar
LeighM
Matrix Staff
Posts: 1888
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 445 times
Been thanked: 640 times
Contact:

Re: I2C ACK

Postby LeighM » Tue Aug 30, 2016 9:15 am

Could you attach your program?
Are you using I2C Master component?
When using the ReceiveByte macro you need to set the "Last" parameter, either 0, or 1 if no more data is to be requested, this will cause a NAK.

User avatar
Alan_37
Posts: 152
Joined: Sun May 01, 2016 8:36 pm
Has thanked: 53 times
Been thanked: 53 times
Contact:

Re: I2C ACK

Postby Alan_37 » Tue Aug 30, 2016 9:53 am

Hi LeighM

Thanks for your quick reply.

So yes I am using I2C Master the ACK in question is being produced by the Renter of the TRANSMIT BYTE ,
it happens only when transmitting the Read command . from the logic Analyzer I am able to see that an ACK
is being sent back from the device to the MCU , but flowcode returns this as a NACK .

The Project is a RS232 to I2c interface if you need a copy I will PM it to you .
But I think this is not necessary because it happens on all devices when Sending the Read Command .

Thanks in Advance

Alan

User avatar
LeighM
Matrix Staff
Posts: 1888
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 445 times
Been thanked: 640 times
Contact:

Re: I2C ACK

Postby LeighM » Tue Aug 30, 2016 10:18 am

Here is another update the problem seems to be only when receiving ACK after the Read Command
below is the waveform of the i2c when Reading from MCP4725 DAC .

Flowcode Gets the ACK Wrong this time outputing it as logic 1 (NACK) .


So when you say "outputing it as logic 1" do you mean that the Flowcode TransmitByte macro is returning a 1 (to indicate Nack received from the device)?

What is your target processor?
And I presume you are using a hardware channel?

User avatar
Alan_37
Posts: 152
Joined: Sun May 01, 2016 8:36 pm
Has thanked: 53 times
Been thanked: 53 times
Contact:

Re: I2C ACK

Postby Alan_37 » Tue Aug 30, 2016 10:29 am

Hi

Yes exactly that is what i meant the TransmitByte macro is returning a 1 when it should return a 0 .

The Target MCU is an ATMEGA2560 ( ARDUINO MEGA2560 R3 ) , also yes I am using hardware channel
I tried to experiment whit the I2C component settings with the intent of fixing the problem but to no avail.

it means that the problem is also present with the default I2c Component Settings.
Attachments
Image 1.png
Image 1.png (12.65 KiB) Viewed 3391 times
Last edited by Alan_37 on Tue Aug 30, 2016 10:44 am, edited 1 time in total.

User avatar
LeighM
Matrix Staff
Posts: 1888
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 445 times
Been thanked: 640 times
Contact:

Re: I2C ACK

Postby LeighM » Tue Aug 30, 2016 10:43 am

Just as a test, could you try disabling Slew and SMB, if you have not tried that already?
Might be worth PMing your code if you could please.
Meanwhile I'll take a look at the CAL code.

User avatar
Alan_37
Posts: 152
Joined: Sun May 01, 2016 8:36 pm
Has thanked: 53 times
Been thanked: 53 times
Contact:

Re: I2C ACK

Postby Alan_37 » Tue Aug 30, 2016 10:51 am

HI LeighM

Just tried to disable SMbus and Slew Rate the problem still remains .

Thanks

User avatar
Alan_37
Posts: 152
Joined: Sun May 01, 2016 8:36 pm
Has thanked: 53 times
Been thanked: 53 times
Contact:

Re: I2C ACK

Postby Alan_37 » Tue Aug 30, 2016 12:59 pm

Hi LeighM

Here is a very simple Program i made now , when sending TEST to RS232 it
will Read the time registers from DS1307 RTC , but it first Sends the ACKS and NACK Received
on every Byte Transmitted .

The DS1307 Register byes dose not match the logic Analyzer cause it was taken at a different time .

But this should clearly show the BUG when sending D1 ( Read Command ) .
Attachments
232test.jpg
232test.jpg (133.54 KiB) Viewed 3374 times
DStest.jpg
(382.49 KiB) Downloaded 1314 times
Dev.rar
(57.11 KiB) Downloaded 116 times