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 support@ccsinfo.com

timeout in #use_i2c

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



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

timeout in #use_i2c
PostPosted: Tue Mar 27, 2007 10:39 am     Reply with quote

Hi,

Don't tell me I'm boring but I'm quite in trouble with i2c and ccs function #use_i2c. In case of noise of bus, or disconnect of slave, the micro remain inside a #use_i2c routine and exit only by wdt reset. The bus is 1 meters to 3 long. I tryed to work on hardare with ferrite beads or resistors without solve the problem.

At the moment I intruduced a timeout controll from TIMER0 interrupt and I solve some problem resetting bits of SSPCON registers. In other case this escape system doesn't work and I remain insyde routine till wdt timeout occure.

In first step I don't want write i2c comunication routine, I wrote it in assembler some times ago, and I want use CCS function.

Is there any possibility to reset i2c comunication, of #use_i2c function, comunication and restart it by software ?
Somebody had my problem and solve it in other way ?

Thanks for suppor me !
PCM programmer



Joined: 06 Sep 2003
Posts: 21414

View user's profile Send private message

PostPosted: Tue Mar 27, 2007 11:30 am     Reply with quote

Give us a complete description of the external i2c hardware.
Post these things:
1. The manufacturer and part number of the i2c chips (or chips).
2. The length of the i2c bus.
3. The type of cable or wire used to connect to the slave chips.
4. The size of the pull-ups.
5. The location of the pull-ups on the bus.
6. The voltage used for the pull-ups.
7. The type of power supply used and its location, etc.

Post these and every other detail about the problem.
Fabri



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

PostPosted: Wed Mar 28, 2007 1:00 am     Reply with quote

Well,

I did many test changing configuration of resistor in series and pull-up without changes.

I have PIC18F2520 as master and PCF8563 in same board. Pull-up are 3K3 ohm. Actually I pull-up each i2c chips, with it's 330 ohm in series , but I tryed with only one pull-up on PIC18F2520 and only one series resistors near PIC without any changes. There are diodes BAT54S to protect SDA and SCL lines Vs. ground and 5Vdc near output bus conector.

External i2c bus is 1 meters long and slave is PIC16F690 with it's series resistors and 3K3 Pull-up. The bus is connected on RJ11 and the cable is 6x28 AWG. The power supply and voltage of pull-up are the same and all 5Vdc trought 1 wire of the bus cable. In bus cable there is also 12Vdc line, I also tryed to disconnect it without changes.

The power supply is a classic with LM7805 from 3VA transformer 230V/12Vac, all components are located in main board.

PICs has, in input pin, it's external pull-up of 10K.
The problem occur when I apply burst noise on power line 230Vac and external i2c bus cable is connected. When I disconnect i2c bus RJ11 in the main board the PIC stop to reset itself. Burst noise level on power supply is 2KV but the problem happen also with 500V.

I did some other test and when I stop master i2c task the problem disappear without any hardware changes.

I tryed to insert ferrite beads, inductor, Murata filters on bus, 5Vdc, ground and power supply without changes. I tryed to increase series resistors without changed the results.

Testing the circuits in debug I found that master stay inside #use_i2c bus in case of bus trouble and exit only when wdt timeout occur.

I hope to give you a complete view of problem and hardware configuration.

Thanks very much !
PCM programmer



Joined: 06 Sep 2003
Posts: 21414

View user's profile Send private message

PostPosted: Wed Mar 28, 2007 11:57 am     Reply with quote

Quote:

The problem occur when I apply burst noise on power line 230Vac
and external i2c bus cable is connected. When I disconnect i2c bus RJ11
in the main board the PIC stop to reset itself. Burst noise level on power
supply is 2KV but the problem happen also with 500V.

You're actually doing pre-production ESD/EMI testing. You should
have said that in the beginning.

Quote:

The power supply is a classic with LM7805 from 3VA transformer
230V/12Vac, all components are located in main board.

Do you an input power filter in front of the transformer ?

I would use a power line filter or a power entry module with a built-in
filter. In other words, let somebody else design the filter for you.
Just buy a power entry filter that you can drop into your product.
Konrad



Joined: 15 Sep 2003
Posts: 34

View user's profile Send private message

Shame CCS I2C does not have a TIMEOUT
PostPosted: Wed Mar 28, 2007 3:48 pm     Reply with quote

You must write your own I2C routines. It is a shame that CCS have no TIMEOUT for I2C as they do for RS232.

If you take I2C out of the box checkout Philips I2C bus extenders. Using the bus extenders will enable you to increase filtering without degrading the I2C signal.

No amount of filtering will compensate for the fact that the bus may be interrupted (or cables removed etc) so use your own routtines.
Fabri



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

PostPosted: Thu Mar 29, 2007 12:37 am     Reply with quote

Hi,

I have a power line filter and without any i2c bus comunication I havent problem up to 3KV of burst in ac lines. As you sad, Konrad, the problem is in software because also cable removed in 60% of case do a reset of master for wdt timeout. Also slave stop to work in case of noise for absence of timeout escape.

I solve some problem testing the situation of compiler's i2c routine, timeout in read and write i2c routines and wdt timeout of slave.

I think CCS must solve also this problem or let the user to complete by oneself the function doing right change. I think CCS have to give open function based on C language as some other present in compiler. I know that user is free from use of inside function of compiler but when it is present it must work as better as possible. I hope you understand.

OK, I decided to write by myself i2c routine as soon as possible.

Thanks for help,
Regards,
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