If you need assistance, please send an email to forum at 4hv dot org. To ensure your email is not marked as spam, please include the phrase "4hv help" in the subject line. You can also find assistance via IRC, at irc.shadowworld.net, room #hvcomm.
Support 4hv.org!
Donate:
4hv.org is hosted on a dedicated server. Unfortunately, this server costs and we rely on the help of site members to keep 4hv.org running. Please consider donating. We will place your name on the thanks list and you'll be helping to keep 4hv.org alive and free for everyone. Members whose names appear in red bold have donated recently. Green bold denotes those who have recently donated to keep the server carbon neutral.
Special Thanks To:
Aaron Holmes
Aaron Wheeler
Adam Horden
Alan Scrimgeour
Andre
Andrew Haynes
Anonymous000
asabase
Austin Weil
barney
Barry
Bert Hickman
Bill Kukowski
Blitzorn
Brandon Paradelas
Bruce Bowling
BubeeMike
Byong Park
Cesiumsponge
Chris F.
Chris Hooper
Corey Worthington
Derek Woodroffe
Dalus
Dan Strother
Daniel Davis
Daniel Uhrenholt
datasheetarchive
Dave Billington
Dave Marshall
David F.
Dennis Rogers
drelectrix
Dr. John Gudenas
Dr. Spark
E.TexasTesla
eastvoltresearch
Eirik Taylor
Erik Dyakov
Erlend^SE
Finn Hammer
Firebug24k
GalliumMan
Gary Peterson
George Slade
GhostNull
Gordon Mcknight
Graham Armitage
Grant
GreySoul
Henry H
IamSmooth
In memory of Leo Powning
Jacob Cash
James Howells
James Pawson
Jeff Greenfield
Jeff Thomas
Jesse Frost
Jim Mitchell
jlr134
Joe Mastroianni
John Forcina
John Oberg
John Willcutt
Jon Newcomb
klugesmith
Leslie Wright
Lutz Hoffman
Mads Barnkob
Martin King
Mats Karlsson
Matt Gibson
Matthew Guidry
mbd
Michael D'Angelo
Mikkel
mileswaldron
mister_rf
Neil Foster
Nick de Smith
Nick Soroka
nicklenorp
Nik
Norman Stanley
Patrick Coleman
Paul Brodie
Paul Jordan
Paul Montgomery
Ped
Peter Krogen
Peter Terren
PhilGood
Richard Feldman
Robert Bush
Royce Bailey
Scott Fusare
Scott Newman
smiffy
Stella
Steven Busic
Steve Conner
Steve Jones
Steve Ward
Sulaiman
Thomas Coyle
Thomas A. Wallace
Thomas W
Timo
Torch
Ulf Jonsson
vasil
Vaxian
vladi mazzilli
wastehl
Weston
William Kim
William N.
William Stehl
Wesley Venis
The aforementioned have contributed financially to the continuing triumph of 4hv.org. They are deserving of my most heartfelt thanks.
Registered Member #56
Joined: Thu Feb 09 2006, 05:02AM
Location: Southern Califorina, USA
Posts: 2445
Ok, I am working on the rev3 version of my GPS tracker, and this time I have (among countless other goodies) a 24FC512 I2C eeprom wired into a pic18f1220. Yes I do have the pullups (2k) on the data/clock lines. I am using mplab and using the c18 compiler, and am using it soft I2C libs.
So, on an I2C bus, you start out by pulling the SDA line low ('start bit') and then you pull the clock line low, change the data line to high/low (depending on if you are sending a high/low bit) let the clock float back high, change data, etc then you have an ack or a stop depending on what you are doing.
EDIT: Turns out that wasn't the problem
After looking at the write bit function again, there was a ! before SCLK_PIN The exact code...
if ( !SCLK_PIN ) // test if clock is low
{ // if it is then ..
if ( Clock_test( ) ) // wait on clock for a short time
{
return ( -1 ); // return with error condition
}
}
else
If SCLK_PIN is high, why is this returning a -1? I tried removing that exclamation mark, and I got some beautiful I2C data on the bus
Now normally this wouldn't be too big of a problem, just remove that exclamation mark, BUT this code is literally 'mission critical' so I would rather do this the right way... I also plan to publish it, so I am trying to avoid modifying the libs more than I have to... I can't imagine the headache that someone would have when they were trying to use the code and it it is doing the opposite of what it should...
edit2: the [code] tags don't seem to like this code either... if ( !SCLK_PIN ) // test if clock is low { // if it is then .. if ( Clock_test( ) ) // wait on clock for a short time { return ( -1 ); // return with error condition } }
Registered Member #56
Joined: Thu Feb 09 2006, 05:02AM
Location: Southern Califorina, USA
Posts: 2445
turns out it was a mix of both problems with the library (one function and one function only was referencing to file that comes with the compiler while the rest were referencing to the header file that you use to configure the whole mess) and that I had the a/d configured incorrectly so the pin always showed as a 0 when poled
I ran into another problem, that the fastest eeprom I could find on an i2c buss has a write time of about 5ms, which caps write speed to about 200B/s, and I plan to save about a KiB/s. So, I am making a raid array of 8x 512kb chips... I call it the EEPROMRAIDARRAYFH (Electronically Erasable Programmable Read Only Memory Redundant Array of Inexpensive Disks From Hell)
Registered Member #96
Joined: Thu Feb 09 2006, 05:37PM
Location: CI, Earth
Posts: 4061
bwahaha :) i was toying with the idea of building a parallel array of 24C256s for this purpose. In my case it was to parallel-store voice samples in realtime with direct D-A conversion.
-A
Beware:- Sellers on Ebay may be scammers in sheep's clothing...
Registered Member #56
Joined: Thu Feb 09 2006, 05:02AM
Location: Southern Califorina, USA
Posts: 2445
Just in case anyone somehow stumbles across this thread when searching for I2C help... When using the hardware I2C module in a PIC (instead of the software one I was using), you must follow each write/read/etc with a IdleI2C();, or the module will not respond to anything don't ask...
Registered Member #65
Joined: Thu Feb 09 2006, 06:43AM
Location:
Posts: 1155
Also note,
1.) Not all i2c chips are internally page mapped the same.
2.) Some can be over clocked to 400kbs (Microchip), to deal with issue 1 page boundaries simply avoid multi-byte block writes and stick to single byte writes.
3.) The exaggerated start/end bit do not have to be a standard period, i2c usually allows the same clock for the staggered signal as long as DATA shift is centered on the CLK period.
4.) Use your own macro defined ports and mask operations, the bit operator macros are often compiler specific inline functions and cause problems.
5.) If you use an IRQ enabled core -- keep in mind the stack may be handled differently on each mcu. Therefore, I often recommend if you are going to bit-bang a signal make sure its the only one on that port (see read-modify-write errata.)
6.) Declare your global constants and port buffer vars in main.c as: volatile static (This can help track down ISR problems...)
This site is powered by e107, which is released under the GNU GPL License. All work on this site, except where otherwise noted, is licensed under a Creative Commons Attribution-ShareAlike 2.5 License. By submitting any information to this site, you agree that anything submitted will be so licensed. Please read our Disclaimer and Policies page for information on your rights and responsibilities regarding this site.