I2CWRITE and 18F4680


Closed Thread
Results 1 to 40 of 41

Hybrid View

  1. #1
    Join Date
    Sep 2007
    Location
    Waco, Texas
    Posts
    151


    Did you find this post helpful? Yes | No

    Default Troubleshooting gear

    Good thoughts, but, I am using a DSO with 100 MHz (not great but fast enough). And, remember (or not) I also remarked the coded for the I2C commands and added the same code used for the 'heartbeat' indication on an LED and watching the scope both lines followed the LED exactly. This should mean no sharts, the 23016 seems not to drag down the output of the PIC, etc.

    By rights it should work - I can not see why it won't. Regardless of the code issues, if the I2C command does anything it should 'wiggle' the pin and I am not seeing it. I have put the init section in its own loop and I still don't see any activity.

    My error label never gets activated so the proc thinks it is communicating with the 23016 but it is not.

    What else can I try? I appreciate the assist....

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    100Mhz DSO should be fast enough...although if you're viewing the signals in real time, you still might not see the pulses. Maybe slow the clock WAY down (i.e. 32khz internal clock) and see if you can see anything. Maybe connect the pins to a pulse counter or a freq counter and see if that shows anything. Or a 555 timer set up as a one-shot pulse stretcher (i.e. 1us pulse gets stretched to 1 second so you can see it)...

    Have you tried connecting a plain ol' 24LC256 serial eeprom type thing to the PIC and working with that just for grins and see what happens? Then after that works, move back to the other chip?


    Quote Originally Posted by ecoli-557 View Post
    ........This should mean no sharts
    You said 'sharts'

  3. #3
    Join Date
    Sep 2007
    Location
    Waco, Texas
    Posts
    151


    Did you find this post helpful? Yes | No

    Default Well, Sharts!

    Well, oops <grin>, so much for engineers spelling......
    No, I have not tried a plain device, perhaps I should. I will try a few more desperate things before that this weekend.

    I will tie a logic probe to one of the pins and see what happens if anything.

    Thanks for the input. Any other ideas??

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


    Did you find this post helpful? Yes | No

    Default

    Seems i've overlooked this one..
    Code:
    @ __CONFIG _CONFIG4L, _LVP_ON_4L & _STVREN_ON_4L & _XINST_ON_4L & _DEBUG_OFF_4L
    Must be off as the compiler don't use the extended instruction set.

    DEFINE I2C_SLOW seems to do weird things here...

    EDIT: WHICH WILL BE FIX IF I DARE TO INSTALL THE LATEST PATCH
    * Adds support for PIC18F6628, 66J11, 66J16, 6723, 67J11, 8628, 86J11, 86J16, 8723 and 87J11.
    * Adds Microchip USB 1.2 fixes for PIC18.
    * Fixes USB for PIC18F87J50 series parts.
    * Sets Adcin default clock to rc for PIC16F882, 883, 884, 886 and 887.
    * Fixes Hpwm pin for PIC12F615, PIC12HV615, PIC16F616, 685, 690, 785, PIC16HV616 and 785.
    * Fixes Hserin2 timeout for PIC18.
    * Fixes I2C_SLOW Define for PIC18.
    * Fixes operator precedence in If..Then for long PIC18 (be safe - use parenthesis.)
    * Fixes Lookup2 for non-long PIC18.
    Last edited by mister_e; - 16th May 2008 at 23:18.
    Steve

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

  5. #5
    Join Date
    Sep 2007
    Location
    Waco, Texas
    Posts
    151


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Seems i've overlooked this one..
    Code:
    @ __CONFIG _CONFIG4L, _LVP_ON_4L & _STVREN_ON_4L & _XINST_ON_4L & _DEBUG_OFF_4L
    Must be off as the compiler don't use the extended instruction set.

    DEFINE I2C_SLOW seems to do weird things here...

    EDIT: WHICH WILL BE FIX IF I DARE TO INSTALL THE LATEST PATCH
    Well now! We have made SOME progress here. Now the proc is upset that it has not heard back from the 23016! I did as Mr. E suggested and disabled the extended stuff in the proc.
    I am working at 20 MHz (tried going to 8 with no help Skimask), so now my LCD message of 'No ACK from I2C device' comes into play. Curious, but re-invigorated......

    I am also now using 2.50A PBP still have not located the MPASM 5.20........

    All comments and advice is needed however.......

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


    Did you find this post helpful? Yes | No

    Default

    Unfortunately, latest MPASM version comes with MPLAB on Microchip website.

    I never use PBP timeout for I2CWRITE... in case you REALLY want.. well, don't forget what i said... the timeout use a GOTO not a GOSUB. The way you did it, it assume a GOSUB.

    Also, use Variable in your I2CWRITE line, numeric value may screw things.
    Last edited by mister_e; - 16th May 2008 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 2007
    Location
    Waco, Texas
    Posts
    151


    Did you find this post helpful? Yes | No

    Default Woo Hoo!

    Thanks to Mr. E's eagle eye, I think the disabling of the enhanced CPU did it! I just glossed right over it.
    My pins now reflect what I think they should - it still doesn't work - but at least it looks like we have made progress.

    Now that I have pins toggling, I now set my sight to the 23016 specifically. The datasheet is confusing and what I use to set it up:
    i2cwrite idata,iclock,$20,$06,[$00,$00],errori2c 'Sets both ports as OUTPUTS
    pause 20

    And to write to it:
    i2cwrite idata,iclock,$20,$00,[loop],errori2c
    pause 20

    may be wrong. According to what I get from the sheet it should be:
    address-command byte-data1-data2

    My address should be zero (0) as all address lines are at ground and command byte of $06 is IODIR0 and command byte $00 is access to GP0 (zero).

    Is this correct?

    -Starting to see some sky here

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