1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Could some have a look at this it's bit bang I2C

Discussion in 'Microcontrollers' started by be80be, Aug 7, 2017.

  1. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,792
    Likes:
    134
    Location:
    morristown,tn
    For some reason it's not finding the WI2C.c
    Code (text):

    :: advisory: (1233) Employing 18F1220 errata work-arounds:
    :: advisory: (1234)  * GOTO instruction at reset vector must be preceded by NOP
    :: advisory: (1234)  * DAW instruction may improperly clear CARRY bit
    :: warning: (1273) Omniscient Code Generation not available in Free mode
    ../WI2C.c:12: warning: (520) function "_i2c_start" is never called
    ../WI2C.c:28: warning: (520) function "_i2c_stop" is never called
    ../WI2C.c:46: warning: (520) function "_bit_out" is never called
    ../WI2C.c:63: warning: (520) function "_bit_in" is never called
    ../WI2C.c:79: warning: (520) function "_i2c_wr" is never called
    ../WI2C.c:99: warning: (520) function "_i2c_rd" is never called
    ../WI2C.c:118: warning: (520) function "_ack_poll" is never called
    ../main.c:169: warning: (1464) number of arguments passed to function "_WI2C_wr_byte" does not match function's prototype
    :0: error: (499) undefined symbol:
        _WI2C_wr_byte(dist/default/production\I2c.X.production.obj)
    (908) exit status = 1
    nbproject/Makefile-default.mk:147: recipe for target 'dist/default/production/I2c.X.production.hex' failed
    make[2]: Leaving directory 'C:/Users/USER/Desktop/Clearning/PICI2C/I2c.X'
    make[2]: *** [dist/default/production/I2c.X.production.hex] Error 1
    make[1]: *** [.build-conf] Error 2
    make: *** [.build-impl] Error 2
    nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failed
    make[1]: Leaving directory 'C:/Users/USER/Desktop/Clearning/PICI2C/I2c.X'
    nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed

    BUILD FAILED (exit value 2, total time: 969ms)
     
     

    Attached Files:

  2. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,145
    Likes:
    907
    Location:
    Rochdale UK
    You need to add this line at the beginning of main...
    #include "PIC16_I2C_BITBANG.h"
     
  3. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,792
    Likes:
    134
    Location:
    morristown,tn
    I have it after
    Code (text):

    #include "xc.h"
    #include "PIC16_I2C_BITBANG.h"

    #define MAX_SIZE  80            // the maximum size for the arrays
     
    It didn't help even the code from microchip does the same thing. Before chip changes
     
    Last edited: Aug 8, 2017
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,792
    Likes:
    134
    Location:
    morristown,tn

    I'm going to download xc8 1.31 and see if it works but on the fip side I maybe done wr0te better code using software peripheral-libraries.
     
  6. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,792
    Likes:
    134
    Location:
    morristown,tn
    This seem to be a problem I download code for a microchip app and after 2 days it still will not compile that's with no changes I look at some new way to use the MCC to make I2C code it sits for a hour and never made a file lol.
    Then I fire up my arduino just to test if I have hardware right nothing happens.
    So I dig for a day and get that my I2c address should be 0x40 nope 0x20 nope 0x27 nope what the heck i finely find where some one had the same problem.
    It's 0x38 all 3 address pin to ground it's PCF8574AP so i got something working


    Going to look at Ian C tut for epprom
     
  7. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,203
    Likes:
    640
    Location:
    Derbyshire, UK
    There's an Arduino I2C example that checks all I2C addresses, and prints a list of all valid addresses it finds, it's easily ported to a PIC processor - and makes it simple to find out what address (or addresses) are on the bus. It can be VERY confusing when setting the I2C address, so it's nice to check that you're using the correct one.
     
    • Like Like x 1
  8. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,792
    Likes:
    134
    Location:
    morristown,tn
    I just found where I went wrong on the address 7 bit not 8 bit 0111000 is 38 hex lol
    I was adding a 0 lol R/W

    I found one that tells if it's the right one " Arduino I2C example that checks all I2C addresses"
    didn't tell what it was tho.
     
  9. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,145
    Likes:
    907
    Location:
    Rochdale UK
    You are using MPLABX... I wrote a bunch of functions and they worked okay!! After several builds (no changes made ) they stopped building and reported a syntax error!!! There absolutely was no error... I copied the function that was giving the issue... Deleted and re inserted the exact same piece of code and low and behold.. working again.. The editor is a load of crap!!!
     
    • Agree Agree x 1
  10. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,792
    Likes:
    134
    Location:
    morristown,tn
    Maybe that's what happening because I had the code working made some changes and my board didn't come on that's because of the address I tested that when I found my mistake i was using 0x40 it's 0x38
     
  11. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,792
    Likes:
    134
    Location:
    morristown,tn
    Well I think I got it figured out now
    Code (text):

    void main(void)
    {

       
         ADDR0=38;
         data=0x00;
        i2c_wr(ADDR0);
        i2c_wr(data);
        i2c_stop;

    while(1)
        {
            // loop forever
            }
    }
     
     
  12. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,792
    Likes:
    134
    Location:
    morristown,tn
    Well no errors but no output too
    Code (text):

    ./main.c:146: warning: (520) function "_ini_gpio" is never called
    ../WI2C.c:12: warning: (520) function "_i2c_start" is never called
    ../WI2C.c:28: warning: (520) function "_i2c_stop" is never called
    ../WI2C.c:99: warning: (520) function "_i2c_rd" is never called
    ../WI2C.c:118: warning: (520) function "_ack_poll" is never called
     
    Looks like they should be working
    Code (text):

    while(1)
        {
        i2c_start;
        i2c_wr(0x38);
        i2c_wr(0x00);
        i2c_wr(0xFF);
        i2c_stop;
            }
     
     
  13. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,792
    Likes:
    134
    Location:
    morristown,tn
    It's alive thanks for the help
     

Share This Page