Hardware I2C


Closed Thread
Results 1 to 12 of 12

Thread: Hardware I2C

Hybrid View

  1. #1
    Join Date
    Jun 2005
    Posts
    29

    Default Hardware I2C

    Is it possible to use the Hardware I2C in PicBasic Pro?

    I need to read faster than I2CREAD PicBasic Pro command. Even with a 20MHz crystal I'm unable to obtain full speed I2C.

    Surely someone have ever work on that issue. Maybe an assembly include?

    Thank you

  2. #2
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi Toley00,

    It may be worth your time to download the I2C Bus Specification manual from Phillips. There are 3 data modes for I2C, Standard Mode = upto 100kbits/sec, Fast Mode = upto 400kbits/sec, and High Speed Mode = 3.4Mbits/sec. I've only used I2C for RTC's using both software I2C and Hardware I2C. I didn't have to set anything up special on my PICs for speed. But you do have to put a 10ms pause after any write command to give it time to catch up or settle down. I have seen some posts on this forum where I2C worked better when it was slowed down.

    Don't know if this helps, but I think maybe their manual might give you a better insight into the whole process.

    BobK

  3. #3
    Join Date
    Jun 2005
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    Thank you BobK for your reply.
    I already know about I2C timing protocol, and I use it in many project already. I just need it to read an EEPROM faster than I2CREAD can do.
    Thanks for your help but a 10ms pause will not give me speed...

  4. #4
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    I don't know what PIC you are using, so I can't promise anything, but I've attached a file containing some portions of code I have used with the hardware I2C on a PIC 18F4620.

    The file is a compilation of cut and past from a few include files, and has only been minimally "cleaned up" for public viewing. It has 4 sections:
    1) Basic PIC and HSEROUT setup (mostly to reinforce what pic and how it's configured)
    2) The meat of the I2C commands
    3) Samples of Large Block Reading/Writing to an EEPROM
    4) Samples of Reading/Writing to an RTC

    Hopefully this will get you started.
    Best of luck,
    Steve B

    Disclaimer: Looking a little closer I recall this being one of my first PBP-ASM items I tackled. It worked, and with other things pressing, I haven't gone back and cleaned things up, like unused variables (DelayCtr1 and DelayCtr2) and rements of HSEROUT commands used to debug.
    Attached Files Attached Files
    Last edited by SteveB; - 20th January 2007 at 05:50. Reason: Added disclaime

  5. #5
    Join Date
    Jun 2005
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    Thank you SteveB, looks like what I need. I will take a closer look and adapt it to my needs. I'm using a PIC16F886, but I think all MSSP modules work the same way, and I only need to read from the EEPROM.

  6. #6
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Toley00 View Post
    Thank you SteveB, looks like what I need. I will take a closer look and adapt it to my needs. I'm using a PIC16F886, but I think all MSSP modules work the same way, and I only need to read from the EEPROM.
    A couple of things right off the top of my head. The buffer size will need to be reduced for a 16F. Also, the way I allocated variables to "BANKA" or "BANKX" in the declaration statements will also need changing. If I get a chance later I'll try to give it a look-over for anything else. As I recall, I think I got the basics of the ASM routines from a Microchip document/source, and adapted them for the 18F. So that might also be an avenue to persue.

    Steve B

  7. #7
    Join Date
    Oct 2005
    Location
    Pinckney, Michigan
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Also consider the RAMTRON FM24C256 32K X 8 eeprom.

    It reads and writes at FULL I2C buss speed. No artificial delays required.

    It is also pin-for-pin compatible with many common serial eeproms, and might just plug directly into your eeprom socket.

Similar Threads

  1. I2C Master/Slave 16F88/16F767 working code
    By DanPBP in forum Code Examples
    Replies: 2
    Last Post: - 23rd October 2012, 22:31
  2. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  3. I2C Master Slave issues.
    By cpayne in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 29th March 2008, 19:33
  4. Hardware I2C
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 13th March 2008, 13:24
  5. Please help with i2cslave i2c slave
    By cycle_girl in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st December 2005, 13:55

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts