SPo3 and I2C


Closed Thread
Results 1 to 8 of 8

Thread: SPo3 and I2C

  1. #1
    fatboylives's Avatar
    fatboylives Guest

    Default SPo3 and I2C

    Hi all.

    I need what might be some basic help with some I2C code.

    I have a SP03 module and the I2C specs for that are on http://www.robot-electronics.co.uk/htm/Sp03doc.shtml
    I am using a 16f877 with 20 mhz crystal. Basically for now I need to read the command status? Can anyone offer a suggestion? Also are the pins I have selected to use for Data and Clock ok on the 877 or should I be using specific pins? Do they need pull up resistors? I have tried different varioations of code and can't get a response....


    My code

    DEFINE OSC 20
    define i2c_slow 1' Tried this as a test


    Wdog Var Portb.7
    DPIN var PORTB.6 ' I2C data pin
    CPIN var PORTB.5 ' I2C clock pin
    talk var portd.2 ' Indicate still busy
    NOP CON 0
    B1 var byte


    High talk 'Unit talks on power up. So indicate
    loop:
    Toggle wdog
    pause 200
    I2CREAD DPIN,CPIN,$C4,[B1] 'Read if still talking

    if b1 > 0 then goto loop
    low talk
    goto loop

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


    Did you find this post helpful? Yes | No

    Default

    Also are the pins I have selected to use for Data and Clock ok on the 877 or should I be using specific pins? Do they need pull up resistors?
    Your selected pins are O.K. Yes you need external Pull-ups ... 4.7K is a common used value.


    Last edited by mister_e; - 22nd January 2005 at 22:42.
    Steve

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

  3. #3
    fatboylives's Avatar
    fatboylives Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks for the help so far. I will give it a go.

    Do I also need the define i2c_slow 1? I read the manual as it is needed if speed is over 4 megs so I take it as yes?

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


    Did you find this post helpful? Yes | No

    Default

    Hi fatboylives, They say they test it over 1MHZ I2C clock so you don't need the define. In PBP I2c SLOW is 100KHZ when not 400KHZ
    Steve

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

  5. #5
    fatboylives's Avatar
    fatboylives Guest


    Did you find this post helpful? Yes | No

    Default

    What happened to your previous post. When I logged in to read your reply re the Define part, I went back to read your earlier post and grab the code and there is none there? I can only see the


    quote:
    --------------------------------------------------------------------------------

    Also are the pins I have selected to use for Data and Clock ok on the 877 or should I be using specific pins? Do they need pull up resistors?
    --------------------------------------------------------------------------------



    Your selected pins are O.K. Yes you need external Pull-ups ... 4.7K is a common used value.




    part. The code you provided has vanished....

    Does this happen or am I just over tired?

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


    Did you find this post helpful? Yes | No

    Default

    Nop, i remove the code myself. I was really not sure of the way we have to talk to this module. Info are not so clear... maybe i'm a pure idiot and over-tired myself too.

    I see different way to access. So i bet we can read from control register like

    ModuleAddress = $C5
    CommandRegister = 0
    I2CREAD DPIN,CPIN,ModuleAddress,CommandRegister,[B1]
    Last edited by mister_e; - 22nd January 2005 at 23:32.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    or

    ModuleAddress = $C4
    CommandRegister = 0
    I2CWRITE DPIN,CPIN,ModuleAddress,[CommandRegister]

    ModuleAddress = $C5
    I2CREAD DPIN,CPIN,ModuleAddress,[b1]

    i don't know :-(
    Steve

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

  8. #8
    fatboylives's Avatar
    fatboylives Guest


    Did you find this post helpful? Yes | No

    Default

    Is there any reason your example shows moduleaddress as $C4 on the write and $C5 on the read? Shouldn't they be the same.

    I might have to use serial instead of I2C if I cannot get it to work...

    Currently I get various values returned and nothi9ng makes sense....... Not unusual for me :-)

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