|
|
View previous topic :: View next topic |
Author |
Message |
esa
Joined: 31 Jan 2008 Posts: 19
|
PIC I2C hardware µP Freeze |
Posted: Thu Jan 31, 2008 2:29 pm |
|
|
Dear users,
I see a problem when using I2C hardware ( USING PIC18F4620)
I search in this forum, but I don't see a post relating this.
The problem :
When the I2C BUS go in short-Circuit ( SCL or SDA), the I2C bus hang and PIC Controller STOP at STEP 2 ( see the listing).
The solution is to RESET the PIC.
This can occur, when a device is defect or a problem on the PCB board.
I search to find a solution.
After a few experiment, I try to use the FORCE_SW and there is no more µP Freeze.
My question :
- Is it a problem for a somes CHIPS when using I2C HArdware ?
- is it better to use the SW version ?
Best Regards
Code: | int IN8574(int device_addr)
{
int io_field,ACK;
printf("\n\r step1");
i2c_start();
printf("\n\r step2");
ACK=i2c_write(PCF8574_ID | device_addr<<1 | I2CREAD);printf("\n\r Write ACK %u",ACK);
printf("\n\r step3");
io_field=i2c_read(0);
printf("\n\r step4");
i2c_stop();
printf("\n\r step5");
return(io_field);
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Feb 03, 2008 1:27 pm |
|
|
Quote: |
When the I2C BUS go in short-circuit ( SCL or SDA), the I2C bus hang. |
Do you mean a short-circuit to ground ? |
|
|
esa
Joined: 31 Jan 2008 Posts: 19
|
|
Posted: Sun Feb 03, 2008 3:02 pm |
|
|
Dear PCM Programmer,
YES, to make a test, I make a short-circuit to ground on SDA or SCL.
I know, this is not a normal situation, but this is to see what could be happening when something could be defect on the board.
On my board there is something wrong ( maybe the PCB or maybe a I2C device ), because, some time, a I2C line (SDA or SCL, I don't remember), stay low.
After this, the only think that I could do to restart to a normal situation, is to make a power OFF and ON again ( not my µP, but the IO device with a lot off PCF8574).
I use this board, for a long time ago with a Industrial PC. And make my one I2C protocol routine. I never see that problem before.
Now, I transfer all my program on a PIC ( a long work ), and I see this problem.
Problem only with the Hardware interface.
With the Software I2C, that's working.
When short-circuit, I don't read nothing on the bus, but the program don't freeze. When the short-circuit go off, the program continue to work ( that's what I need).
Thanks for your input
Regards
Eric |
|
|
esa
Joined: 31 Jan 2008 Posts: 19
|
|
Posted: Tue Feb 05, 2008 2:58 pm |
|
|
I have more informations.
My IO board (with PCF8574) is connected to my µP board.
When I disconnect the IO board and reconnect it, some time, the program freeze.
The SDA line stay LOW on my IO board.
Maybe a PCF8574 device waiting something ?
I make a restart of my µP board without success. The program halt on the first reading/writing attempt on the I2C bus.
So I decide to try to use the Software switch for I2C.
Redownload the µP.
Restart µP ( and my IO board is always with the SDA line low ).
The program can now restart without having a problem with this situation ( SDA LINE LOW ). And the program continue to work without problem.
So, by using the software parameter, it is possible to came back to a normal situation.
Somebody already see this behavior ?
Best Regards |
|
|
boattow Guest
|
I2C problems? |
Posted: Wed Feb 06, 2008 10:51 am |
|
|
You might take a look at the Microchip website for the errata on your microcontroller. There have been many people having problems using I2C on the PIC18f4620 family due to some bugs. For one thing, there are sometimes some issues with the power on reset and you must make the 2 I2C lines as outputs, clear LATC, then set them as inputs, then configure I2C registers as you normally would. Another thing which can cause the I2C to not work at all, or work for a period and then quit (freeze) is the BRG number is incorrect in the datasheet so the clock speed is incorrect. Check the errata for the new BRG value to be written to the SSPAAD register.
As a guest, this site won't let me paste the URL so go to Microchip's website and search for this document and I think you will be able to solve your problems: 80224d.pdf
Good luck,
Boattow |
|
|
Guest
|
|
Posted: Fri Feb 08, 2008 5:51 am |
|
|
I think you need a timeout on your hardware I2C function. You could rewrite the I2C functions a wee bit. So that if the SCLK line gets stuck low for an excessive amount of time you do not hang up your micro and the possible faulty I2C comms can be detected within your code. If you use a watchdog, it will just reset your chip and it will detect the same situation again and again keep on doing the same thing, whereas re-writing the I2C functions will allow you to do something about the fault. |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Fri Feb 08, 2008 11:53 am |
|
|
esa wrote: | I have more informations.
My IO board (with PCF8574) is connected to my µP board.
When I disconnect the IO board and reconnect it, some time, the program freeze. |
I have lots of products in the field using I2C with the PIC18F4620. I have a high degree of confidence with it. However what you are describing here is more likely an input latch up problem which can happen when the signals lines are connected before the ground raid is connected. Even a few nanoseconds in this state can lead to latch up.
Going back to your original problem description, if the PIC is always the IC2 master, then you can place low value resistors (such as 470R) in series with the clock and data lines. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
esa
Joined: 31 Jan 2008 Posts: 19
|
|
Posted: Sat Feb 09, 2008 4:11 am |
|
|
Thanks to everybody for your help.
To solve the problem and to avoid hang up the processor, I prefer to use the DIRECTIVE 'FORCE_SW'
#use i2c(Master,Slow,sda=PIN_C4,scl=PIN_C3,force_SW).
In this case, I can disconnect my IO board and I never freeze the code.
So, thanks to Guest, but software I2C is already make by CCS and good working
Thanks to Andrew : I already use 390 R in serial on each device.
And 4K7 pullUp resistor.
Regards
Case solved. |
|
|
|
|
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
|