Using I2C with FullSpeed USB


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154

    Default Using I2C with FullSpeed USB

    Hi,

    I was finally able to get my USB Device recognized and working, but I encountered a serious problem as I was adding functionality. It seems that the I2CREAD command takes too much time and the USB service is lost.

    Does anyone have any ideas on how to get around this problem? The I2C device I am polling is a MCP23016 I/O expander.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default

    I have one idea, I'd like opinions on it please. Lack of experience prevents me from knowing if I am just heading for another set of problems.

    How about adding a PIC 16F628 to poll the MCP23016 and use hardware USART to send a word whenever data from the I/O Expander changes?

    I checked the datasheet and the 16F628 can go up to 5000 KBAUD at 20MHz while in Synchronous mode. Is that fast enough without the USB service dropping?

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    If you have a device with a hardware I2C port, you could use that instead of PBP's bit-banging ones. The hardware approach would take a lot less CPU cycles.
    Charles Linquist

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default

    Can you elaborate just a bit more please?

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  5. #5
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    A lot of the newer PICs have a hardware I2C port. The 18F8722 for example, has two ports. Microchip calls these "SSP" or "MSSP" ports.

    Just as SERIN and SEROUT use pure software to manipulate ports, I2CREAD and I2CWRITE use software to simulate a true hardware I2C port. Since everything is done in software, the processor is tied up 100% of the time during the entire operation.
    HSERIN and HSEROUT use the PIC's USART. If these are used, the software simply needs to write to or read from a register, and hardware takes over to send or receive the bit stream. From a processor standpoint, HSEROUT is hundreds of times faster than SEROUT.
    The same thing is true with I2C. If you can use the PIC's built-in hardware to do the task, it is MUCH quicker than using I2CREAD and I2CWRITE.
    Unfortunately, I'm in the process right now of learning how to use the specialized I2C hardware. As a result, I'm not much of a resource (at least not today) when it comes to actual implementation.
    Charles Linquist

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default

    I'm using the 18F4550 as main processor and it has both the USB and SPP features. I have a LCD tied to the SPP port already, and nearly all the other pins are used.

    Is there a device that could take I2C input and then output through USART? I know MicroChip has a lot of 'stuff', but I don't have any experience in this area.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    how many byte do you read at the time?

    still working with a single byte at the time? if so, just do loop and insert a USBSERVICE inside

    As now i didn't use I2CREAD/WRITE with USB ones so...The MSSP is also suggest by me.

    Charles.. i'm with you
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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. Simple USB Comms Problem
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th January 2010, 20:17
  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