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

Status
Not open for further replies.

#### be80be

##### Well-Known Member
For some reason it's not finding the WI2C.c
Code:
:: 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)

#### Attachments

• 110 KB Views: 35

#### be80be

##### Well-Known Member
I have it after
Code:
#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:

#### be80be

##### Well-Known Member
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.

#### be80be

##### Well-Known Member
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

#### Nigel Goodwin

##### Super Moderator
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.

#### be80be

##### Well-Known Member
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.

#### Ian Rogers

##### User Extraordinaire
Forum Supporter
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!!!

#### be80be

##### Well-Known Member
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

#### be80be

##### Well-Known Member
Well I think I got it figured out now
Code:
void main(void)
{

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

while(1)
{
// loop forever
}
}

#### be80be

##### Well-Known Member
Well no errors but no output too
Code:
./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:
while(1)
{
i2c_start;
i2c_wr(0x38);
i2c_wr(0x00);
i2c_wr(0xFF);
i2c_stop;
}

#### be80be

##### Well-Known Member
It's alive thanks for the help

Status
Not open for further replies.