nono240
Reged: Feb 09 2005
Posts: 76
Loc: FRANCE
|
|
I've implemented the G.Neiss's code in 100% C for my 18F8722.
It's *ALMOST* the same except 16 bit device's address is not implemented since it was useless for me (but VERy easy to implement).
Don't forget the interrupt routine :
Code: --------------------------------------------------------------------------------
//---------------------------------------------------------------------// //-------------------------Low priority Interrupt----------------------// //---------------------------------------------------------------------// void interrupt low_priority lowISR() {
//-------------Interrupt on I2C events----------------// if(SSP1IF && SSP1IE) I2Cmachine(); }
-------------------- In a world without walls nor Windows, who needs Gates ?
|
G.Neiss
  
Reged: Dec 26 2004
Posts: 474
Loc: germany
|
|
It's a good 'reverse engeniering' of my assembler code 
I would use it as a base point for implementing I2C on other processors. Why ? Look at the generated code and You will see, the assembler only version is faster. But of course it's not portable. So thanks for translating it.
ciao Guenter
|
nono240
Reged: Feb 09 2005
Posts: 76
Loc: FRANCE
|
|
Quote:
It's a good 'reverse engeniering' of my assembler code 

Quote:
Look at the generated code and You will see, the assembler only version is faster.
Sure ! Assembler is ALWAYS faster. This version is for 'educational' purposes -> "I2C for newbies"
Quote:
But of course it's not portable.
Sure too...
Quote:
So thanks for translating it.
Thanks to you for your original code.
-------------------- In a world without walls nor Windows, who needs Gates ?
|
2171984
Reged: Oct 14 2005
Posts: 1
|
|
thanks
|
dimithri
Reged: Oct 16 2005
Posts: 1
|
|
hello since we're on the topic I thought of asking this...
I'm having trouble with a project i've undertaken recently where i am trying to interface a Anybus module to a PIC18f452. Everything was going fine until i found that I don't have enough I/O pins to address the Anybus module's 12bit address. Therefore I wanted to use a PCF8575 I/O expander chip which uses I2C interface. But I'm already using the pins SCL and SDA pins for the DAC which I use (its interfaced using the SPI interface) hence I've got a problem. I'm already using PORTD an PORTE for the Parallel Slave Port (PSP) to get data to the Anybus and PORTA is used for the Analog to Digital converter and I only have PORTB (8bits) left. I've tried to implement a latching system where i address the 12bits with 8bits by de-multiplexing but its very complex. I'm using the PIC18f452 chip as stated before with MICRO CHIP MPLAB C18 compiler.
Hope somebody can help.. Thanks, regards, Dimithri
|
Dan Henry
Guru
  
Reged: Oct 16 2003
Posts: 3856
Loc: Colorado
|
|
A few ideas:
- Have SPI and I2C devices share the MSSP pins. Although I have never tried it, apparently some have done it. For example, see Mixing I2C and SPI on the same pins.
- Implement I2C in software on available GPIO pins (i.e., bitbang).
- Move your DAC's SPI interface to available GPIO pins in implement SPI in software (i.e., bitbang), since bitbanging SPI is (arguably) easier than bitbanging I2C, and put the I/O expander on the MSSP's hardware I2C pins and switch the MSSP to I2C mode.
|
Bolt
 
Reged: Oct 29 2003
Posts: 48
Loc: The Netherlands
|
|
Change the DAC to an I2C version?... Use the I/O expander and the DAC on the I2C bus...
-------------------- Marko
eMbed Engineering
|
jlian168
stranger
Reged: Mar 31 2009
Posts: 1
|
|
Deal sir: Pardon me,My english not well. I've a question for you? I use the the I2C interrupt routine in PIC16F877A & DS1307, But not stable,Because some time is good and sometime is bad!I don't know why? // 1.DS1307 no connect Battery. 2.use SDA RC4 & SCL RC3(all pull-high) 3.MPLAB V8.10 4.PICC16 V9.6 std 5.cpu XTAL=4MHz 6.DS1307 xtal=32.768kHz // Could you help me? Thanks you very much. Have a nice day. /*************************************************/ 2009/04/02: Now i think it may be no ack by battery no connect! Because i connect the battery is running good. /*************************************************/
Edited by jlian168 (Thu Apr 02 2009 12:01 AM)
|