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 CCS Technical Support

turn off i2c with FORCE_HW

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



Joined: 19 Jan 2004
Posts: 1

View user's profile Send private message

turn off i2c with FORCE_HW
PostPosted: Mon Jan 26, 2004 11:09 am     Reply with quote

Hello,

I have a program which runs a series of tests on hardware to which the PIC16F873 is connected. The bulk of the tests require me to communicate VIA i2c, which is no problem.

However, one of the tests require that I manually toggle output bits on and off, and read inputs. This would not be a problem except that the lines I must manually toggle are harware connected to the i2c lines. I am not using the i2c at the time when I must manipulate the bits, but when using the i2c port in forced hardware mode (FORCE_HW) I am unable to manipulate logic levels on those pins (PIN_C3 and C4).

If I remove the FORCE_HW option I can control the logic level, and everything is ok, except my program is a little to large to fit in the PIC's ROM when I have software I2C. So I need to use FORCE_HW.

So I guess I'm wondering if there is a way to set i2c to FORCE_HW and turn it off again half way through the application, so I can manipulate PIN_C3 and C4.

Thank you for your time.

- Ajay Sancheti
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 26, 2004 12:32 pm     Reply with quote

You should read the data sheet. In the I/O Ports section,
look at the comments on "peripheral override".
The "Force_HW" mode uses the Hardware i2c module.
This overrides the normal port i/o ability on pins C3 and C4.

Here is a program which shows how to temporarily
disable the Hardware i2c. Then you can change those pins.

#include "16F877.h"
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#use i2c(Master, sda = PIN_C4, scl = PIN_C3, Force_HW)


#bit SSPEN_BIT = 0x14.5

#define enable_ssp() output_float(PIN_C3); \
output_float(PIN_C4); \
SSPEN_BIT = 1

#define disable_ssp() SSPEN_BIT = 0

main()
{

disable_ssp();

enable_ssp();

while(1);
}
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