how to use I2C and 2nd I2C built in peripherals?


+ Reply to Thread
Results 1 to 12 of 12
  1. #1
    Member kuhrig's Avatar
    Join Date
    Aug 2005
    Posts
    123
    Thumbs Up
    Received: 6
    Given: 0
    Total Downloaded
    4.82 GB

    0 Not allowed!

    Default how to use I2C and 2nd I2C built in peripherals?

    I'm working with a Microchip micro with 2 built in I2C ports.

    How can I use the built in I2C peripherals? Which Proton commands to use?
    Specially how to use first and second I2C?
    I understand how to initialize the ports with the I2C registers, but not how I can easily read and send using Proton.

    I am using Busin and Busout in a different project but these commands are software implementations.

    Thanks.
    Kai

  2. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Prolific Poster rcurl's Avatar
    Join Date
    Mar 2002
    Posts
    1,899
    Thumbs Up
    Received: 32
    Given: 58
    Total Downloaded
    2.38 GB

    0 Not allowed!

    Default Re: how to use I2C and 2nd I2C built in peripherals?

    Hi Kai-
    Look in the manual for the following commands: HbStart, HbStop, HbRestart, HbusAck, HbusNack, Hbusin, Hbusout. The "H" at the beginning of these commands stands for "hardware", which means you'll be using the PIC's MSSP (I2C) hardware module. You'll also find the same commands without the "H" in front. Those are the software-only I2C commands.

    There is also a declare: Hbus_Bitrate constant, but in most cases you can leave that alone.

    Tips: A common mistake with I2C is to omit the pullup resistors. You'll need a resistor connected from SCL to Vdd and another one from SDA to Vdd. Try to avoid using a PIC that has Peripheral Pin Select (PPS) for your first I2C project. That adds a BIG extra layer of complexity.

    -Rick

  4. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    565
    Thumbs Up
    Received: 40
    Given: 7
    Total Downloaded
    3.89 GB

    0 Not allowed!

    Default Re: how to use I2C and 2nd I2C built in peripherals?

    You have not specified which device you are using, but I presume from your question it has two MSSP modules and you want to use both for almost simultaneous communication with 2 I2C devices as opposed to connecting multiple I2C devices to a single I2C bus and reading them sequentially.

    If that is correct then I am not 100% certain of this but I think the Hbus commands can only use the 1st MSSP module, it has been a while since I read that section of the manual but I do not recall there being a mechanism for specifying which MSSP module it should use if there is more than one.
    You could use the Hbus commands for one of the I2C busses and the I2Cin/I2Cout commands to run the second I2C bus as a software (bit bashed bus) or read the data sheet and write you own code, writing to the applicable registers to set up the MSSP modules and then Read/Write to the applicable SSPBUF registers to send/receive data.

  6. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Member kuhrig's Avatar
    Join Date
    Aug 2005
    Posts
    123
    Thumbs Up
    Received: 6
    Given: 0
    Total Downloaded
    4.82 GB

    0 Not allowed!

    Default Re: how to use I2C and 2nd I2C built in peripherals?

    Hi Stephen,
    thanks for your quick reply. I am using an PIC24FJ128GA308 (I know it should be Proton24 talk but thought it's the same and here is more traffic) with 2 built in I2Cs (not MSSPs)
    Kai

  8. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Member kuhrig's Avatar
    Join Date
    Aug 2005
    Posts
    123
    Thumbs Up
    Received: 6
    Given: 0
    Total Downloaded
    4.82 GB

    0 Not allowed!

    Default Re: how to use I2C and 2nd I2C built in peripherals?

    Hi Rick,
    thanks for your quick replay.
    It has 2 built in I2Cs not MSSPs. The Hbstart etc commands use the MSSP peripheral.
    Kai

  10. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    Senior Member GAMBOA's Avatar
    Join Date
    Nov 2004
    Posts
    469
    Thumbs Up
    Received: 22
    Given: 0
    Total Downloaded
    276.92 MB

    0 Not allowed!

    Default Re: how to use I2C and 2nd I2C built in peripherals?

    Kuhrig,

    The MSSP (Master Synchronous Serial Port) module is the hardware part of the microcontroller that can function as I2C and as SPI. You can program a series of registers to behave in one way or another.
    I2C by software works well and if you don't have a great need for speed it will work well and flexibly because you can choose the pins you want.
    If instead you want to handle I2C hardware using MSSP then you can go to a library that Les has made for PIC24: Hbus.inc and Hbus2.inc. I have not tried them.
    Regards,
    Gamboa

  12. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    Prolific Poster John Drew's Avatar
    Join Date
    Feb 2002
    Posts
    2,989
    Thumbs Up
    Received: 97
    Given: 34
    Total Downloaded
    5.17 GB

    0 Not allowed!

    Default Re: how to use I2C and 2nd I2C built in peripherals?

    Kai,
    When posting try to use the best section of the Forum. That way we'll find things in future.
    Most of us will always see a post no matter where you post because we use the What's New button at the top to see posts we have not previously read. By posting in this area you've thrown us off the track for a while. I'm just trying to help for future posts.
    Best wishes
    John

  14. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #8
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    565
    Thumbs Up
    Received: 40
    Given: 7
    Total Downloaded
    3.89 GB

    1 Not allowed!

    Default Re: how to use I2C and 2nd I2C built in peripherals?

    Quote Originally Posted by kuhrig View Post
    Hi Stephen,
    thanks for your quick reply. I am using an PIC24FJ128GA308 (I know it should be Proton24 talk but thought it's the same and here is more traffic) with 2 built in I2Cs (not MSSPs)
    Kai
    Les is obviously the ultimate authority on whether or not the existing Proton I2C commands will currently work with this device or be modified to do so at some point as I think the Proton commands were written to use I2C functions of the more traditional MSSP module and so may not work with the dedicated I2C of this device which appear to be a totally different animal, consequently you may have to write your own code for that.

  16. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  17. #9
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,805
    Thumbs Up
    Received: 376
    Given: 182
    Total Downloaded
    2.09 GB

    0 Not allowed!

    Default Re: how to use I2C and 2nd I2C built in peripherals?

    Because of the "massive", and unnecessary changes Microchip keep making to the MSSP peripherals on each device family, the HBus commands are now "legacy", and will not be supported with future devices, both 8-bit and 16-bit devices.

    Instead, a set of simple procedures in an inc file library must be created by the user for the device family they are using that have changed so much. Now that Proton also has procedures, it will also help other users who want ot use I2C or SPI for a certain device family. As a single person having to make changes for multiple devices that I cannot afford to purchase and, simply, do not have time to write for and test for "free", the MSSP peripheral commands will not be supported in future compiler versions. The original HBus commands will still be usable, but the compiler will produce a reminder stating that they are legacy and not recommended.

  18. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  19. #10
    Member kuhrig's Avatar
    Join Date
    Aug 2005
    Posts
    123
    Thumbs Up
    Received: 6
    Given: 0
    Total Downloaded
    4.82 GB

    0 Not allowed!

    Default Re: how to use I2C and 2nd I2C built in peripherals?

    Les,
    thanks for clarification. Thanks for all your support.

    @John Thanks for your reply. Which section should I have used? Can you move it?

    @ all: Anybody out there who can write an I2C inc file library (paid for)? Please PM me. Thanks.

    Rgds
    Kai

  20. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  21. #11
    Prolific Poster John Drew's Avatar
    Join Date
    Feb 2002
    Posts
    2,989
    Thumbs Up
    Received: 97
    Given: 34
    Total Downloaded
    5.17 GB

    0 Not allowed!

    Default Re: how to use I2C and 2nd I2C built in peripherals?

    G'day Kai,
    It would have been better to put it in the Proton 24 section. It helps people find it in future.
    I'm not able to move it.
    All the best
    John

  22. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  23. #12
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,805
    Thumbs Up
    Received: 376
    Given: 182
    Total Downloaded
    2.09 GB

    0 Not allowed!

    Default Re: how to use I2C and 2nd I2C built in peripherals?

    Most users do not realise the massive differences that Microchip are making to different families of devices, and most of the differences are unnecessary! For many years, the peripherals worked with a set pattern and set names but that has been thrown out of the window in recent years. :-( It seems that when a new group come into the design office, they change things based upon how they see things, regardless if they need changing or not! Unfortunately, most of the design changes seems to be pointless.

    Send me an email (send a PM and I'll give you my email address) and I'll create a library for that device for you, for both I2C peripherals. I'll try my best to match it into the compiler's existing commands, as well as a seperate .inc file that can have its procedures accessed seperately to make you program more flexable.
    Last edited by top204; 29th October 2020 at 12:29.

  24. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. 2nd I2C on the 18F26K22 with use of 2nd MSSP
    By jan in forum Website / Forum Issues
    Replies: 2
    Last Post: 14th January 2020, 21:35
  2. Replies: 4
    Last Post: 10th November 2019, 01:55
  3. I2c
    By PAKirk in forum Proton Plus Compiler v3
    Replies: 21
    Last Post: 11th February 2010, 12:54
  4. [SOLVED !] I2c
    By ADLIN SYSTEMS in forum Proton Plus Compiler v3
    Replies: 1
    Last Post: 20th March 2007, 10:37
  5. I2c
    By ajh_nubia in forum Wish List / Product Feedback
    Replies: 0
    Last Post: 16th February 2002, 22:17

Tags for this Thread

Posting Permissions

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