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

FORCE_HW & FORCE_SW

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



Joined: 07 Apr 2010
Posts: 15

View user's profile Send private message

FORCE_HW & FORCE_SW
PostPosted: Tue Apr 13, 2010 7:06 am     Reply with quote

Hi all

What difference between FORCE_HW and FORCE_SW when use #USE I2C.

thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 13, 2010 12:51 pm     Reply with quote

The CCS manual says:
Quote:

#USE I2C

FORCE_HW Use hardware I2C functions.
FORCE_SW Use software I2C functions.

Hardware i2c is only available on specific pins on the PIC chip.
These pins are labeled SDA and SCL in the PIC data sheet.
The PIC must have an SSP (slave only) or MSSP module (master
and slave) to do hardware i2c. CCS does hardware i2c by talking
to the hardware i2c module registers in the PIC. The hardware
module handles controlling the i2c bus.

Software i2c is available on most i/o pins on the PIC.
CCS does software i2c by "bit banging" the i/o pins with code.
CCS controls the i2c bus directly with code.
msa



Joined: 07 Apr 2010
Posts: 15

View user's profile Send private message

PostPosted: Tue Apr 13, 2010 1:13 pm     Reply with quote

Thank you for your answer.

with regards
tim_sid



Joined: 11 Apr 2014
Posts: 16

View user's profile Send private message

PostPosted: Fri Apr 11, 2014 2:14 am     Reply with quote

so, for software I2C is simple ccs I2C_read() and I2c_write functions are enough or I need to use some library performing some bit banging? can I have some simple code or clue, Please?
oxo



Joined: 13 Nov 2012
Posts: 219
Location: France

View user's profile Send private message

PostPosted: Fri Apr 11, 2014 5:01 am     Reply with quote

tim_sid wrote:
so, for software I2C is simple ccs I2C_read() and I2c_write functions are enough.....?


Yes, you use i2c_read and i2c_write. Look in the help file
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Apr 11, 2014 5:20 am     Reply with quote

Just one additional note: You didn't mention if you want to use it on a master or on a slave device. Software I2C on a master works great but don't try to use it on a slave.
tim_sid



Joined: 11 Apr 2014
Posts: 16

View user's profile Send private message

PostPosted: Fri Apr 11, 2014 5:49 am     Reply with quote

Thank you so much for quick replies.
Ckielstra, I just need my PIC working in Master mode for writing to slave device.
RoGuE_StreaK



Joined: 02 Feb 2010
Posts: 73

View user's profile Send private message

PostPosted: Mon Apr 14, 2014 7:37 pm     Reply with quote

Is it correct to say that hardware i2c (and PWM, and SPI etc) works independent of your other code, that once the command is given the hardware itself performs the task, freeing up the processor to do other things? Kind of like delegating a job to someone else, you can continue with more important tasks whilst they do the tedious repetitious stuff?
Ttelmah



Joined: 11 Mar 2010
Posts: 19266

View user's profile Send private message

PostPosted: Tue Apr 15, 2014 12:27 am     Reply with quote

Yes.

However for I2C the difference is normally tiny. At 100KHz, it only takes 80uSec to send a byte. Using software I2C won't normally reach this rate (except on a fast PIC), but the actual time to send a byte is still small.
Different from RS232 where byte times are often several mSec.

Best Wishes
jeremiah



Joined: 20 Jul 2010
Posts: 1320

View user's profile Send private message

PostPosted: Tue Apr 15, 2014 8:50 am     Reply with quote

Note that however, while hardware does work independently of software in general, you still have to consider driver and built in function implementations. Some of those will loop infinitely waiting for a hardware flag to set before moving on. For example, if you use putc or printf to print to a hardware UART, it will wait until the buffer has room before adding the next character to the outgoing buffer. Using getc will wait until there is a character before moving on.

You can get around these limitations in various ways:
1. Some peripherals have built in support functions or parameters for avoiding those delays
2. Some peripherals can be implemented using interrupts to get around this (usually with extra code from you)
3. You can write your own drivers or peripheral functions to use instead.
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