Req. I2C Scanner - Page 2


+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Req. I2C Scanner1485 days old

  1. #11
    Senior Member tumbleweed's Avatar
    Join Date
    May 2011
    Posts
    471
    Thumbs Up
    Received: 58
    Given: 0
    Total Downloaded
    330.54 MB

    0 Not allowed!

    Default Re: Req. I2C Scanner

    This is the way I would do it...
    Code:
    nDevices = 0
    For address = 0 To 254 Step 2
      HbStart			' send START
      HBusOut address     ' send ADDR byte w/RW=0 (write)
      If PP4.0 = 0 Then	' check ACK result (also in STATUS.0)
        HRSOut CStr deviceFound,Hex address,13
        Inc nDevices
      EndIf
      HbStop			' send STOP
    Next
    You should get an ACK when you try to write an address byte to a slave device (first byte after a START). Trying to read isn't how to do it.
    You can skip the "odd addresses" since those are really just the read address.

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.

  • #12
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,155
    Thumbs Up
    Received: 74
    Given: 173
    Total Downloaded
    4.98 GB

    0 Not allowed!

    Default Re: Req. I2C Scanner

    @Tumbleweed. Thanks for posting code. I had tried both PP4=0 and STATUS.0=0 (see post #9) but on a 18F25K50 at least both are always 0 and thus detect detect every possible address.
    George.

  • 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
    Senior Member tumbleweed's Avatar
    Join Date
    May 2011
    Posts
    471
    Thumbs Up
    Received: 58
    Given: 0
    Total Downloaded
    330.54 MB

    0 Not allowed!

    Default Re: Req. I2C Scanner

    Looks like you're right, George.
    I took a look at the asm and maybe I'm missing something but it looks like it's anding the result and losing the flag.

    Try this and see if it works any better:
    Code:
    symbol ACKSTAT 6
    nDevices = 0
    For address = 0 To 254 Step 2
      HbStart			' send START
      HBusOut address     ' send ADDR byte w/RW=0 (write)
      If SSP1CON2.ACKSTAT = 0 Then	' check ACK result
        HRSOut CStr deviceFound,Hex address,13
        Inc nDevices
      EndIf
      HbStop			' send STOP
    Next

  • 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.

  • #14
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,155
    Thumbs Up
    Received: 74
    Given: 173
    Total Downloaded
    4.98 GB

    0 Not allowed!

    Default Re: Req. I2C Scanner

    Yep that does the trick. While I have your interest, any idea how to detect Ack on bitbang I2C?
    George.

  • 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
    Senior Member tumbleweed's Avatar
    Join Date
    May 2011
    Posts
    471
    Thumbs Up
    Received: 58
    Given: 0
    Total Downloaded
    330.54 MB

    0 Not allowed!

    Default Re: Req. I2C Scanner

    That one looks like it just might work using PP4.0 or STATUS.0 to check the ACK bit, so try:
    Code:
    ' bit-banged
    Dim PP4 As Byte System
    ndevices = 0
    For addr = 0 To 254 Step 2
      BStart			' send START
      BusOut addr     ' send ADDR byte w/RW=0 (write)
      If PP4.0 = 0 Then	' check ACK result (also in STATUS.0)
        Inc ndevices           ' device found
      EndIf
      BStop			' send STOP
    Next
    Don't have anything to test it on at the moment...

  • 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.

  • #16
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,155
    Thumbs Up
    Received: 74
    Given: 173
    Total Downloaded
    4.98 GB

    0 Not allowed!

    Default Re: Req. I2C Scanner

    Tumbleweed, once again thanks for taking the trouble and posting code, as I expected it works a treat on both STATUS.0 and PP4.0

    For completeness I'll post the final version.
    Attached Files Attached Files
    Last edited by towlerg; 19th September 2019 at 14:56.
    George.

  • 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. Req: LED ACTIVEX FOR VB2008
      By CharlieBrown in forum The Lounge
      Replies: 6
      Last Post: 28th November 2010, 11:30
    2. RTD switching in temperature scanner
      By shantanu@india in forum The Lounge
      Replies: 23
      Last Post: 19th August 2009, 15:22

    Members who have read this thread : 50

    Actions :  (Set Date)

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

    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