Hello,
I am using pic18F46k22 for I2C slave - working OK. If change CPU to 18f26k22 communication not working. Programs is same in boths CPU.
i2c slave
Moderator: Benj
- 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
Which channel and pins are you using?
Channel 2 is on different pins for each of these devices.
Channel 2 is on different pins for each of these devices.
Re: i2c slave
Im using chanell 1 - pin connect OK.
after start about 5 sec i2c bus communication stoped.
after start about 5 sec i2c bus communication stoped.
- 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
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...
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...
Re: i2c slave
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
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 177 times
- 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
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
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