Hardware I2C


Closed Thread
Results 1 to 22 of 22

Thread: Hardware I2C

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kamikaze47 View Post
    I need to interface a PIC18F4550 to a 24FC512 EEPROM chip which uses an I2C.
    The 18F4550 has hardware based I2C capability, but reading through that section of the data sheet has got me fairly confused.
    Does anyone have any advice on using the hardware based I2C capabilities?
    I2C is a bit of a pain in hardware. http://www.nxp.com/acrobat_download/...8/39340011.pdf
    explains the inner working of I2C relatively easily.
    Why hardware I2C vs. PBP's I2C handling?

  2. #2
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    This is for the same project that I was having difficulties with my interrupts interrupting SEROUT commands. I assume the I2CREAD and I2CWRITE would have the same problems when interrupted?
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kamikaze47 View Post
    This is for the same project that I was having difficulties with my interrupts interrupting SEROUT commands. I assume the I2CREAD and I2CWRITE would have the same problems when interrupted?
    I2CRead/I2CWrite can be as fast as the PIC and/or device can make use of them...
    Same thing with SerIn/SerOut...if the PIC is set up to run fast and the device can run just as fast, they don't take up much time.
    The I2C commands won't get interrupted by ON INTERRUPT but they would get interrupted by DT's fast interrupts.
    I would think you could easily go into the I2C macro's and add a couple of lines to turn the interrupts on and off before and after the I2C command (or do it manually each time an I2C command is executed).

    Forget that other link. I think this one is better:
    http://www.i2c-bus.org/I2C-Primer.520.0.html

  4. #4
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    I am using ASM interrupts, as some of them are time critical. I also would prefer not to turn off the interrupts during I2C usage, as I don't want to miss any interrupt events.

    I just found this on MicroChip's site. It looks helpful: http://ww1.microchip.com/downloads/e...tes/00989A.pdf
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kamikaze47 View Post
    I am using ASM interrupts, as some of them are time critical. I also would prefer not to turn off the interrupts during I2C usage, as I don't want to miss any interrupt events.

    I just found this on MicroChip's site. It looks helpful: http://ww1.microchip.com/downloads/e...tes/00989A.pdf
    Looks helpful, but I'd suggest reading that other site on I2C and learn a bit about what has to happen behind the scenes for an I2C transaction to be successful.
    I2C isn't like serial. You can't really just 'plug a byte' and assume the receiver got it (well, you can for a few things). There's a few steps involved (start, control, address, data, stop/ack/nak, etc). Some under PIC control, some under user control.

    How time critical are those 'time critical' interrupts?
    Keep in mind that I2C is a lot faster than 9600 baud serial...

  6. #6
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Thanks skimask, i'll give it a read.

    I guess when I think about it, they aren't extremely time critical. My main worry was about missing interrupt events. But I guess as long as the interrupt does trigger - say a millisecond late, that shouldn't impact the performance.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kamikaze47 View Post
    I guess when I think about it, they aren't extremely time critical.
    It happens...more often than not.
    You hear 'I need sub-nanosecond accuracy to time my slot cars!'...come on...do you really?

    My main worry was about missing interrupt events. But I guess as long as the interrupt does trigger - say a millisecond late, that shouldn't impact the performance.
    Well if I knew what the trigger and the items involved were, I might have a better idea laying in the back of my head on how to compensate...

Similar Threads

  1. Hardware I2C
    By Toley00 in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 3rd July 2022, 10:53
  2. I2C Master/Slave 16F88/16F767 working code
    By DanPBP in forum Code Examples
    Replies: 2
    Last Post: - 23rd October 2012, 22:31
  3. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  4. I2C Master Slave issues.
    By cpayne in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 29th March 2008, 19:33
  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 : 0

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