I2C bus 2


+ Reply to Thread
Results 1 to 11 of 11

Thread: I2C bus 21068 days old

  1. #1
    Member ricardourio's Avatar
    Join Date
    Jan 2007
    Posts
    221
    Thumbs Up
    Received: 6
    Given: 54
    Total Downloaded
    3.89 GB

    0 Not allowed!

    Default I2C bus 2

    Hi Les, I working with PIC18F26K22 and it brought the necessity to use second I2C bus commands, like HBStart2, Hbusout2....

    Ricardo Urio

  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
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,584
    Thumbs Up
    Received: 337
    Given: 161
    Total Downloaded
    1.99 GB

    1 Not allowed!

    Default Re: I2C bus 2

    You're better off using the I2COut and I2Cin commands Ricardo. They are just as fast, and easier to manage. They are also able to be used multiple times using any pins of a microcontroller for SDA and SCL.

    Really, the hardware I2C peripherals only come in as mandatory if used as a slave device, otherwise, bit-bashed I2C is just as good, if not a bit better because the querks of the MSSP peripheral don't come into play.

  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
    Henk57
    Guest Henk57's Avatar

    0 Not allowed!

    Default Re: I2C bus 2

    If a slave (must) use clock-stretching then it wouldn't work with I2COut.
    The Bus will stop and a Reset or powercycle must be invoked.

    I don't know if I2COut have that option allready, its about 2years ago that I encounter this with some slave's.
    For that reason I must use HBusOut.

    Henk.
    Last edited by Henk57; 23rd June 2017 at 20:53.

  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 ricardourio's Avatar
    Join Date
    Jan 2007
    Posts
    221
    Thumbs Up
    Received: 6
    Given: 54
    Total Downloaded
    3.89 GB

    0 Not allowed!

    Default Re: I2C bus 2

    As well, with time critical firmwares, we can't use MSSP2 interrupts using I2COut.

    Ricardo Urio

  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
    Prolific Poster shantanu@india's Avatar
    Join Date
    Feb 2007
    Posts
    1,705
    Thumbs Up
    Received: 7
    Given: 21
    Total Downloaded
    827.23 MB

    0 Not allowed!

    Default Re: I2C bus 2

    Saw this thread late........do we really need two separate I2C connections in any application ?.......one is sufficient to communicate with the peripherals having different addresses. The basic idea behind two hardware MSSP modules is carrying out two different kind of communications concurrently......one I2C , another SPI.....etc.
    Shantanu

  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
    Mentcleer
    Guest Mentcleer's Avatar

    0 Not allowed!

    Default Re: I2C bus 2

    Hi Henk57,

    I do not understand "clock-stretching" ....
    I am working with I2C and I have connected a Clock, Accelerometer (MMA7455LT) and a Temperature sensor in PIC18F26K22 all with different I2C addresses.


    The accelerometer is not because it stops the system is frozen and I have to do a Reset.


    It is possible that it is for what you comment and if that is the solution I apply.


    Thank you.

  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
    Member ricardourio's Avatar
    Join Date
    Jan 2007
    Posts
    221
    Thumbs Up
    Received: 6
    Given: 54
    Total Downloaded
    3.89 GB

    0 Not allowed!

    Default Re: I2C bus 2

    Hi Shantanu,

    As example, my circuit uses MSSP1 to communicate between 3 microcontrollers and 4 DAC. One microcontroller is responsible by a critical high pressure closed loop control, so it controls a valve current, using a separate DAC, connected to MSSP2 of this specific microcontroller, while the main system is working with MSSP1.

    Ricardo Urio

  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
    Prolific Poster shantanu@india's Avatar
    Join Date
    Feb 2007
    Posts
    1,705
    Thumbs Up
    Received: 7
    Given: 21
    Total Downloaded
    827.23 MB

    0 Not allowed!

    Default Re: I2C bus 2

    HI Ricardo,
    What you say is reasonable.......using the second MSSP for the critical application.
    Just a thought.......for high pressure valve control , if there is a feedback failure then the DAC output can shoot up & the results can be catastrophic.
    You must be using some kind of software interlock for that.
    But software is not always foolproof.....some hardware safety mechanism should also be there.
    Shantanu

  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
    Member ricardourio's Avatar
    Join Date
    Jan 2007
    Posts
    221
    Thumbs Up
    Received: 6
    Given: 54
    Total Downloaded
    3.89 GB

    0 Not allowed!

    Default Re: I2C bus 2

    Hi Shantanu,

    You are right and both safety systems were implemented. Software has a current limit for each pressure range and a mechanic security valve opens around 2150 BAR (my working pressure is up to 2000 bar=29.000 PSI)

    Ricardo Urio

  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
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,584
    Thumbs Up
    Received: 337
    Given: 161
    Total Downloaded
    1.99 GB

    1 Not allowed!

    Default Proton I2C libraries for MSSP1 and MSSP2 peripherals

    Here you go Ricardo...

    I've created 2 libraries to implement I2C via both MSSP1 and/or MSSP2. All routines are written in BASIC, so they can be altered as much as you require. They are extremely easy to use, and are very efficient.

    Within the zip file there is also 3 demo programs showing them interfacing with separate eeproms, and 2 eeproms in the same program. There's also an Isis simulation showing everything working. Shown below:

    Here's one of the demo programs that uses MSSP2:
    Code:
    ' Demonstrate the routines for I2C using the device's MSSP2 peripheral
    ' Write bytes to a 24LC256 I2C eeprom, then read them back and displays them on the serial terminal
    ' Written by Les Johnson for the Proton BASIC Compiler
    '
        Device = 18F25K22                           ' Select a device with two I2C peripherals
        Declare Xtal = 64
    
        Declare Hserial_Baud = 9600                 ' Set USART1 baud rate to 9600
    '
    ' Define the pins used for the device's MSSP2 peripheral
    '
    $define Hbus2_SCL_Pin PORTB.1
    $define Hbus2_SDA_Pin PORTB.2
    
        Include "Hbus2.inc"                         ' Load the I2C MSSP2 routines into the program
    '
    ' Create some variables for the demo
    '
        Dim wAddress As Word                        ' 16-bit address of eeprom
        Dim ByteIn As Byte                          ' The byte received
        Dim Byteout As Byte                         ' The byte transmitted
    
    '-----------------------------------------------------------------------------------------------
    ' The main program starts here
    ' Write bytes to a 24LC256 I2C eeprom, then read them back and display them on the serial terminal
    '
    Main:
    '
    ' Write to the eeprom
    '
        For wAddress = 0 To 9                               ' Create a 10 element loop
            Byteout = wAddress + 100                        ' Load the value to write to eeprom 1
            Hbus2_Start()                                   ' Send a Start condition
            Hbus2_Set_SlaveAddress(% 01010000, Hbus2_Write) ' Send the Device + Slave address + Write bit
            Hbus2_Write_Byte(wAddress.HighByte)             ' Send the High Byte of the address
            Hbus2_Write_Byte(wAddress.LowByte)              ' Send the Low Byte of the address
            Hbus2_Write_Byte(Byteout)                       ' Send the value of Byteout to the eeprom
            Hbus2_Stop()                                    ' Send a Stop condition
            DelayMS 5                                       ' Give time for the byte to be stored in the eeprom's matrix
        Next
    '
    ' Read from the eeprom
    '
        HRSOutLn "From eeprom 2:"
        For wAddress = 0 To 9                               ' Create a 10 element loop
            Hbus2_Start()                                   ' Send a Start condition
            Hbus2_Set_SlaveAddress(% 01010000, Hbus2_Write) ' Send the Device + Slave address + Write bit
            Hbus2_Write_Byte(wAddress.HighByte)             ' Send the High Byte of the address
            Hbus2_Write_Byte(wAddress.LowByte)              ' Send the Low Byte of the address
    
            Hbus2_ReStart()                                 ' Send a ReStart condition
            Hbus2_Set_SlaveAddress(% 01010000, Hbus2_Read)  ' Send the Device + Slave address + Read bit
            Hbus2_Read_Byte(ByteIn)                         ' Read the byte from the eeprom
            Hbus2_Nack()                                    ' Send a Nack condition
            Hbus2_Stop()                                    ' Send a Stop condition
            HRSOutLn "Address ", Dec wAddress, " is holding ", Dec ByteIn ' Display what was read on the serial terminal
            DelayMS 50                                      ' Delay so we can see things happen
        Next
        Stop
    
    '-----------------------------------------------------------------------------------------------
    ' Setup for 64MHz operation using a 16MHz crystal
    '
    Config_Start
        FOSC = HSHP           ' HS oscillator (high power > 16 MHz)
        PLLCFG = On           ' Oscillator multiplied by 4
        PRICLKEN = On         ' Primary clock enabled
        FCMEN = Off           ' Fail-Safe Clock Monitor disabled
        IESO = Off            ' Internal/External Oscillator Switchover mode disabled
        PWRTEN = On           ' Power up timer enabled
        BOREN = SBORDIS       ' Brown-out Reset enabled in hardware only (SBOREN is disabled)
        BORV = 190            ' Brown Out Reset Voltage set to 1.90V nominal
        WDTEN = Off           ' Watch dog timer is always disabled. SWDTEN has no effect.
        WDTPS = 128           ' Watchdog Timer Postscale 1:128
        CCP2MX = PORTC1       ' CCP2 input/output is multiplexed with RC1
        PBADEN = Off          ' PORTB<5:0> pins are configured as digital I/O on Reset
        CCP3MX = PORTB5       ' P3A/CCP3 input/output is multiplexed with RB5
        HFOFST = On           ' HFINTOSC output and ready status are not delayed by the oscillator stable status
        T3CMX = PORTC0        ' Timer3 Clock Input (T3CKI) is on RC0
        P2BMX = PORTB5        ' ECCP2 B (P2B) is on RB5
        MCLRE = EXTMCLR       ' MCLR pin enabled, RE3 input pin disabled
        STVREN = Off          ' Stack full/underflow will not cause Reset
        LVP = Off             ' Single-Supply ICSP disabled
        XINST = Off           ' Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
        Debug = Off           ' Disabled
        Cp0 = Off             ' Block 0 (000800-001FFFh) not code-protected
        CP1 = Off             ' Block 1 (002000-003FFFh) not code-protected
        CP2 = Off             ' Block 2 (004000-005FFFh) not code-protected
        CP3 = Off             ' Block 3 (006000-007FFFh) not code-protected
        CPB = Off             ' Boot block (000000-0007FFh) not code-protected
        CPD = Off             ' Data EEPROM not code-protected
        WRT0 = Off            ' Block 0 (000800-001FFFh) not write-protected
        WRT1 = Off            ' Block 1 (002000-003FFFh) not write-protected
        WRT2 = Off            ' Block 2 (004000-005FFFh) not write-protected
        WRT3 = Off            ' Block 3 (006000-007FFFh) not write-protected
        WRTC = Off            ' Configuration registers (300000-3000FFh) not write-protected
        WRTB = Off            ' Boot Block (000000-0007FFh) not write-protected
        WRTD = Off            ' Data EEPROM not write-protected
        EBTR0 = Off           ' Block 0 (000800-001FFFh) not protected from table reads executed in other blocks
        EBTR1 = Off           ' Block 1 (002000-003FFFh) not protected from table reads executed in other blocks
        EBTR2 = Off           ' Block 2 (004000-005FFFh) not protected from table reads executed in other blocks
        EBTR3 = Off           ' Block 3 (006000-007FFFh) not protected from table reads executed in other blocks
        EBTRB = Off           ' Boot Block (000000-0007FFh) not protected from table reads executed in other blocks
    Config_End
    In order for all programs to use the "Hbus1.inc" and "Hbus2.inc" libraries, place them in the User's Includes folder: C:\Users\User's Name\PDS\Includes\

    I2C libraries for MSSP1 and MSSP2

    Click image for larger version

Name:	Eeproms.jpg
Views:	60
Size:	101.4 KB
ID:	3310

    Last edited by top204; 30th June 2017 at 20:13.

  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
    Member ricardourio's Avatar
    Join Date
    Jan 2007
    Posts
    221
    Thumbs Up
    Received: 6
    Given: 54
    Total Downloaded
    3.89 GB

    0 Not allowed!

    Default Re: Proton I2C libraries for MSSP1 and MSSP2 peripherals

    Hi Les,

    Very good, I will use it soon.

    Ricardo Urio

  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.

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. I2C bus
    By Peter Truman in forum Proton Plus Compiler v3
    Replies: 6
    Last Post: 29th July 2012, 07:14
  2. I2C 2 parts on 1 bus
    By Peter Truman in forum Proton Plus Compiler v3
    Replies: 5
    Last Post: 3rd July 2011, 04:11
  3. [SOLVED !] I2C Bus
    By ADLIN SYSTEMS in forum Wish List / Product Feedback
    Replies: 7
    Last Post: 12th August 2009, 15:42
  4. Why is my I2C bus not working?
    By C H Whitehead in forum The Lounge
    Replies: 24
    Last Post: 3rd February 2006, 01:41
  5. I2C bus woes HELP!!!!!!!
    By BenBarber in forum Proton Plus Compiler v3
    Replies: 14
    Last Post: 3rd November 2005, 17:53

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