EmbeddedRelated.com
Forums
Memfault Beyond the Launch

"C" source code for I2C slave PIC16F81x

Started by Tesvit February 16, 2005
Hi All,

I have to write an PIC16F819 based application that act as I2C slave
device.
As for compiler I will use HI-TECH PICC together with MPLAB.  Could
anyone, please, send me sample "C" code for that.  I have no assembler
knowledge :-(
Any link/source/hint would be appreciated.

Thank you,

Tesvit.
"Tesvit" <tesvit@gmail.com> skrev i meddelandet
news:696487f0.0502152035.41996840@posting.google.com...
> Hi All, > > I have to write an PIC16F819 based application that act as I2C slave > device. > As for compiler I will use HI-TECH PICC together with MPLAB. Could > anyone, please, send me sample "C" code for that. I have no assembler > knowledge :-( > Any link/source/hint would be appreciated. > > Thank you, > > Tesvit.
There is an AVR application note written in assembler. - Might be easier to run on an AVR though ;-) I am sure there hsould be something for the PIC though, google? -- Best Regards, Ulf Samuelsson ulf@a-t-m-e-l.com This message is intended to be my own personal view and it may or may not be shared by my employer Atmel Nordic AB
Tesvit wrote:
> Hi All, > > I have to write an PIC16F819 based application that act as I2C slave > device. > As for compiler I will use HI-TECH PICC together with MPLAB. Could > anyone, please, send me sample "C" code for that. I have no assembler > knowledge :-( > Any link/source/hint would be appreciated. > > Thank you, > > Tesvit.
An I2C slave is more difficult to implement in software than a master, due to the fact that the master is controlling the timings alone. You need at least a hardware clock clamp to make sure that the slave can catch up with the master. See the I2C specifications on clock stretching and bus synchronization. -- Tauno Voipio tauno voipio (at) iki fi
On Wed, 16 Feb 2005 07:09:55 GMT, Tauno Voipio
<tauno.voipio@iki.fi.NOSPAM.invalid> wrote:

>An I2C slave is more difficult to implement in software >than a master, due to the fact that the master is controlling >the timings alone.
I2C Slave is implemented in hardware on an 18F819/819. Which will reduce the complexity of your software
On 15 Feb 2005 20:35:05 -0800, Tesvit wrote:

> Hi All, > > I have to write an PIC16F819 based application that act as I2C slave > device. > As for compiler I will use HI-TECH PICC together with MPLAB. Could > anyone, please, send me sample "C" code for that. I have no assembler > knowledge :-( > Any link/source/hint would be appreciated. > > Thank you, > > Tesvit.
Check out application note AN734 "Using the PICmicro SSP for Slave I2C Communication" at www.microchip.com. Good description of the SSP and C source code example. Bob
> I2C Slave is implemented in hardware on an 18F819/819. > Which will reduce the complexity of your software
Hi, Yes, I found that 16F819 support slave I2C in hardware. But fastest way is modify an working "C" sample. All sources I found are in assembler and are not suitable for me because I can not modify it :-( My assembler knowledge is too poor... Thank you.
Tesvit wrote:
> >> I2C Slave is implemented in hardware on an 18F819/819. >> Which will reduce the complexity of your software > > Yes, I found that 16F819 support slave I2C in hardware. But > fastest way is modify an working "C" sample. All sources I found > are in assembler and are not suitable for me because I can not > modify it :-( My assembler knowledge is too poor...
Then I suspect you should not be using any PIC. Their capabilities do not include executing standards conforming C code, and anything you do is pure guesswork. -- "If you want to post a followup via groups.google.com, don't use the broken "Reply" link at the bottom of the article. Click on "show options" at the top of the article, then click on the "Reply" at the bottom of the article headers." - Keith Thompson
In article <4213783E.1A578224@yahoo.com>, CBFalconer wrote:
> Then I suspect you should not be using any PIC. Their capabilities > do not include executing standards conforming C code, and anything > you do is pure guesswork.
That's a bit of an exaggeration. The PIC C I use has one deficiency from the standard: support for recursion. That does not render the rest of what I do as "pure guesswork." -- John W. Temples, III
> Check out application note AN734 "Using the PICmicro SSP for Slave I2C > Communication" at www.microchip.com. Good description of the SSP and C > source code example.
Hi Bob, Thank you for URL. I checked it: http://ww1.microchip.com/downloads/en/AppNotes/00734a.pdf but there is just assembler source. I need "C" one... Regards, tesvit.
Hi,
As I sent in my first message, I am using HI-TECH's PICC compiler that
has just few limitations (lack of recursion and some
pointer-to-function issues).
Cheers!


Memfault Beyond the Launch