I'm having a problem sending data from an i2c slave (pic 16f616) to an i2c master (pic 16f616). I have no problem sending from master to slave, but when I try to receive from the slave I always get 0's. I can receive data from an i2c eeprom so i'm thinking it's a problem in the i2c slave send part of the i2c.h or maybe im not doing something right. Here is my code:
Master code
;Chip Settings
#chip 16F616,8
#config OSC=INTRC_OSC_NOCLKOUT, MCLRE=OFF
;Defines (Constants)
#define SendAHigh porta.1= on
#define SendALow porta.1 = off
#define RecAHigh porta.2 on
#define RecALow porta.2 off
#define I2C_MODE Master
#define I2C_DATA PORTA.4
#define I2C_CLOCK PORTA.5
;Variables
Dim ValueIn As byte
InitSer 1, r4800, 1, 8, 1, None, Invert
Do Forever
Wait 250 ms
I2CStart
I2CReceive ValueIn
I2CStop
SerPrint 1, ValueIn
Loop
Bowlofpudding, I was just getting interested in trying out the I2C function when you made your post. I was able to verify your results using a 16F88 using ports b.0 and b.1. It was interesting that I had to enable the weak pullups before it would work? That verifies that the I2C.h file is in error. Thanks for your tip. Ed
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
yeah i used actual pullups in my circuit, either 10k or 100k i forget which, one on data and one on clock. i only just now learned how to enabled weak pull ups which were helpful to eliminate the physical ones for my buttons
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
according to your datasheet, only port B has internal pull ups, and they cant be individually set. so if you want to set one, you have to set them all. configure them as inputs and put this line of code in Great Cow Basic
<code>
Set NOT_RBPU Off
</code>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm having a problem sending data from an i2c slave (pic 16f616) to an i2c master (pic 16f616). I have no problem sending from master to slave, but when I try to receive from the slave I always get 0's. I can receive data from an i2c eeprom so i'm thinking it's a problem in the i2c slave send part of the i2c.h or maybe im not doing something right. Here is my code:
Master code
Slave code
I seem to have found the problem. inside the i2c.h file, in the part where it sends as slave it has this line of code
I2CByte = 0
I removed that and now its sending what it should. maybe someone should make a note of this, and why was this is there to begin with?
Bowlofpudding, I was just getting interested in trying out the I2C function when you made your post. I was able to verify your results using a 16F88 using ports b.0 and b.1. It was interesting that I had to enable the weak pullups before it would work? That verifies that the I2C.h file is in error. Thanks for your tip. Ed
yeah i used actual pullups in my circuit, either 10k or 100k i forget which, one on data and one on clock. i only just now learned how to enabled weak pull ups which were helpful to eliminate the physical ones for my buttons
Hi, sorry to thread hijack but how do you use the internal weak pull up resistors?
thanks Dan
i should have mentioned its a 16F77.
according to your datasheet, only port B has internal pull ups, and they cant be individually set. so if you want to set one, you have to set them all. configure them as inputs and put this line of code in Great Cow Basic
<code>
Set NOT_RBPU Off
</code>