i2c slave

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Post Reply
gpql
Posts: 4
Joined: Sun Mar 13, 2016 4:00 pm
Contact:

i2c slave

Post by gpql »

Hello,
I am using pic18F46k22 for I2C slave - working OK. If change CPU to 18f26k22 communication not working. Programs is same in boths CPU.

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: i2c slave

Post by LeighM »

Which channel and pins are you using?
Channel 2 is on different pins for each of these devices.

gpql
Posts: 4
Joined: Sun Mar 13, 2016 4:00 pm
Contact:

Re: i2c slave

Post by gpql »

Im using chanell 1 - pin connect OK.
after start about 5 sec i2c bus communication stoped.

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: i2c slave

Post by LeighM »

So, are you saying that 18F46K22 works fine, but 18F26K22 works for 5 seconds then stops?
Is there any difference in hardware? Is this with your own circuit and board?
Could you add some outputs, say to LEDs, and place some debug code in your project such that the outputs tell you where in your program it has stopped?
Or UART debug output, or Flowcode ICD...

gpql
Posts: 4
Joined: Sun Mar 13, 2016 4:00 pm
Contact:

Re: i2c slave

Post by gpql »

Hi,
step by step
1. Testing program in pic18f46k22 - working OK
2. Change processor type to pic18f26k22
3. setting i2c for new processor
4. start program in 18f26k22
5. Program not working and delay 5s - pic18f26k22 stoped I2C bus. Example connecting pcf8574 to bus not working.
PCF8574 is converter for LCD.
6. Change processor pic18f46k22 all components conected to i2c bus working corect.
7. Program is same in two processor.

include program in flowcode
Attachments
2._I2C_Slave_LEDs (1)_z lcd.fcfx
(14 KiB) Downloaded 176 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: i2c slave

Post by LeighM »

Hi,
I'm not sure why there should be a difference.
But one thing I noticed is that you have a misunderstanding about the "Last" parameter of the Slave_RxByte(),
this parameter should be set to 0 on all but the last byte read, where it should be set to 1.
You are attempting to read three bytes and set the "Last" parameter to 1,2,3, so all reads will be assumed to be the last byte to be read and the Nak, rather than Ack, will be sent.
Hope that helps,
Leigh

Post Reply