I2C causes processor to hang {Solved}

A forums to allow bugs and problems with Flowcode v7 to be reported and resolved.

Moderator: Benj

Post Reply
howard123
Posts: 75
Joined: Thu May 24, 2012 1:15 pm
Location: Cape Town
Has thanked: 30 times
Been thanked: 28 times
Contact:

I2C causes processor to hang {Solved}

Post by howard123 »

Hello All

Hope you can help me with this problem.

I have a PIC18F46K22 connected to a DS3231 RTC using I2C communicating over hardware channel 2.

I am not able to read from the RTC without causing my processor to hang. This is caused by the SDA line being held low - there is no NAK generation.
LA test A.JPG
LA test A.JPG (61.59 KiB) Viewed 3011 times

The Flowcode sequence used in Test A is normal however changing it and unusually including a I2CMaster1::TransmitByte(0) in the sequence just before the Stop results in a NAK as in Test B (red dot on the logic analyser record). In this case the SDA line is released and all is fine.
FC test B.JPG
FC test B.JPG (142.17 KiB) Viewed 3011 times
LA test B.JPG
LA test B.JPG (62.29 KiB) Viewed 3011 times

Writing to the RTC in the standard way is fine and my addressing for this device is 0xD0 for master write and 0xD1 for master read.

Strangely this segment worked in FC6 and possibly in early FC7 but I cant remember with certainty.

Thanks a lot

Howard
FC7.2.1.4 patched yesterday

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 causes processor to hang

Post by Benj »

Hi Howard,

For your last receive byte before the stop you should set the "Last" parameter to 1 to generate the NAK.

Let us know how you get on.

howard123
Posts: 75
Joined: Thu May 24, 2012 1:15 pm
Location: Cape Town
Has thanked: 30 times
Been thanked: 28 times
Contact:

Re: I2C causes processor to hang

Post by howard123 »

Thanks Ben
This has worked
regards
Howard

Post Reply