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

I2C, FORCE_HW, slow, fast trivia - trying to sort out things

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







I2C, FORCE_HW, slow, fast trivia - trying to sort out things
PostPosted: Fri Nov 27, 2009 6:21 am     Reply with quote

All right, compiler v4.093, i'm starting to experience with I2C, so i'm not a pro, but i know little (from the forums) about:

_ pull-ups check
_ i know about the i2c_read(0) NAK for the last read from master vs slaves
_ Master:

#use i2c(Master,fast=100000,I2C1)
#define SLAVE_W 0x14
#define SLAVE_R 0x15

_ Slave:
#use i2c(Slave,I2C1,address=0x14,FORCE_HW)

I'm not asking "my system isn't working", actually i would like to know why and how it is working :D

Actually my questions try to cover a broad range of issues on the I2C topic; yes, i've read quite a few pages from the forums and that's why i wanted to sum up everything in here ;) - I'm using a PIC16F690 to experience, one as master, the slave with a adc_read to feed data; the master is asking the slave for the value.

1. Why the master is not working with the FORCE_HW directive? i read "0" and the code is running (i have a toggle led in the main loop)

2. Why I2C_speed(xx) and I2C_poll() are not working without force_hw?

3. How can i tell if the master PIC is using a software implementation or HW of the I2C?

4. What's the differences between "fast=100000" and "slow" parameter? any adavantages?

My small setup is working, only i'm just wondering of so many small things not explicitely written, changed, hacks and mods to make it go Smile

Tnx!
Ttelmah
Guest







PostPosted: Fri Nov 27, 2009 10:09 am     Reply with quote

The I2C_SPEED question, is the same as for the 'set_uart_speed' function.
The software I2C, in common with the async serial, is done by using custom timing loops to get all the timings. To change the speed, you have to change the actual code in all these loops (not just changing a counter, but actually altering the number of nop instructions etc.). Hence you can't change the speed for the software code 'on the fly'. You can change the speed, by setting up two streams with the required speeds, and selecting the one you want, but this then generates two sets of software I2C driver code, with all the loops altered.....

I2C_POLL, tells you that the hardware has received a byte. No hardware to do this with software I2C...
Remember that with the hardware, reception goes on independant of the running code. With software, there is no such ability, and nothing for I2C_POLL to tell you.

At heart, no difference between using 'fast=xxx', and using 'slow'. Slow is the older syntax, and until fairly recently, was the only 'speed' option available.

Without seeing your code, difficult to know 'why' it doesn't work with FORCE_HW. However, 'what compiler version'. There are issues on some compilers not initilalising sme peripherals correctly, and this could be your I2C problem. Also, when using the hardware peripheral, the inputs are Schmitt trigger inputs, requiring better pull-ups, than wil work for the software.

Best Wishes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Nov 27, 2009 10:09 pm     Reply with quote

Quote:

3. How can I tell if the master PIC is using a software implementation or
HW of the I2C?

Go to Project Options in MPLAB (or the equivalent in the CCS IDE) and
set the .LST file format to Symbolic. Compile your program and look
at the code for the i2c operations. If the code is talking to hardware
registers such as SSPBUF, SSPSTAT, etc., then it's using the hardware
i2c module. (Or attempting to use it. There could be bugs.)
Also, you must specify the hardware i2c pins (SDA and SCL) in the
#use i2c() statement.
Guest








PostPosted: Wed Dec 02, 2009 4:29 am     Reply with quote

Thanks all for the initial suggestions.

FORCE_HW: I'm using the PIC16F690, the master has
Code:
#use i2c(master,slow,i2c1,force_hw)

Where the "i2c1" is the identifier for the first i2c hw peripheral in the PIC (found this definition in the ccs manual, should be similar to word "uart1" for the rs232 declaration).

With force_hw the behaviour is that I always read "0". Disabling force_hw the system is running.

I'll proceed with the PCM Programmer suggestions, meanwhile, has anyone succeeded in using force_hw, and with what pic?

Tnx.
mewanchyna



Joined: 21 Nov 2005
Posts: 15
Location: Montreal, Canada

View user's profile Send private message Send e-mail

16f690 force_hw CCS ver. 4.030
PostPosted: Sat Feb 27, 2010 11:15 am     Reply with quote

For the record, I have similar issues with the the software and hardware I2C. Code works in software but not when I "force_hw". I'm using CCS 4.030. I will post any results that I find.
ckielstra



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

View user's profile Send private message

PostPosted: Sat Feb 27, 2010 11:58 am     Reply with quote

Quote:
I'm using CCS 4.030
The first v4.0xx releases were bad quality. Don't use anything before v4.070.
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