|
|
View previous topic :: View next topic |
Author |
Message |
emaxxenon
Joined: 21 Jan 2020 Posts: 42
|
i2C 2 Slave and IR Led Problem |
Posted: Thu Mar 12, 2020 2:59 am |
|
|
Hello,
I have 1 master and 2 slave cards.
I use pic18f25k22 on all cards.
There are 16 ir leds in slave cards.
Master sends information to slave cards to turn these leds on one by one.
It reads one by one and sends it to plc.
It worked correctly in simulation tests.
I tested it for 3 ir leds on the board and it worked correctly.
But now I am having trouble for 16 ir leds when I test it on pcb.
Why could it be?
Master Code:
Code: |
#include <18F25K22.h>
#fuses hsh,wdt,put,noprotect
#use delay(crystal=20MHz,clock=20MHz)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,ERRORS)
#use i2c(Master, sda=PIN_C4, scl=PIN_C3, force_hw, restart_wdt)
#byte TXSTA1 = 0x0FAC
#bit TRMT = TXSTA1.1
#byte PIR1 = 0x0F9E
#bit TX1IF = PIR1.4
#bit RC1IF = PIR1.5
#byte TXREG1 = 0x0FAD
////////////////////////////////////////////////////////
#define R_SLAVE1_W 0x10
#define R_SLAVE1_R 0x11
////////////////////////////////////////////////////////
#define T_SLAVE1_W 0x20
#define T_SLAVE1_R 0x21
////////////////////////////////////////////////////////
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <PetitModbusCcs.h>
#include <PetitModbusCcs.c>
#include <PetitModbusPortCcs.h>
#include <PetitModbusPortCcs.c>
#include <PetitRegConstantCcs.c>
#use fast_io(a)
#use fast_io(b)
#use fast_io(c)
unsigned int16 Tmr1_Deger=64911;
unsigned int16 Timer1_Tick_Counter;
#INT_TIMER1
void TIMER1_isr(void)
{
Set_Timer1(Tmr1_Deger);
Timer1_Tick_Counter ++;
PetitModBus_TimerValues();
clear_interrupt(INT_TIMER1);
}
#INT_RDA
void RDA_isr(void)
{
ReceiveInterrupt(getch());
RC1IF=0;
}
void main()
{
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1|RTCC_8_bit);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
Set_Timer1(Tmr1_Deger);
Setup_Timer_2(T2_Disabled,0,1);
Setup_CCP1(CCP_OFF);
Setup_Comparator(NC_NC_NC_NC);
Setup_Adc(ADC_OFF);
Setup_Adc_Ports(NO_ANALOGS);
disable_interrupts(INT_TIMER0);
disable_interrupts(INT_TIMER1);
disable_interrupts(INT_RDA);
disable_interrupts(INT_TBE);
disable_interrupts(GLOBAL);
set_tris_A(0x00);
set_tris_B(0x00);
set_tris_C(0xF9);
output_A(0x00);
output_B(0x00);
output_C(0x00);
delay_ms(50);
disable_interrupts(INT_TIMER0);
enable_interrupts(INT_TIMER1);
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
InitPetitModbus(1);
while(TRUE)
{
int16 data;
////////////////////////////////////////////////////////
for(int i=0; i<16; i++)
{
i2c_start();
i2c_write(T_SLAVE1_W);
i2c_write(i);
i2c_stop();
i2c_start();
i2c_write(R_SLAVE1_W);
i2c_write(i);
i2c_stop();
delay_ms(50);
i2c_start();
i2c_write(R_SLAVE1_R);
data = i2c_read(0);
i2c_stop();
ProcessPetitModbus();
PetitRegisters[i].ActValue=data;
}
////////////////////////////////////////////////////////
}
}
|
Transmitter IR Code:
Code: |
#include <18F25K22.h>
#fuses hs,nowdt,put,noprotect
#use delay(crystal=20MHz,clock=20MHz)
#use i2c(SLAVE, SDA=PIN_C4, SCL=PIN_C3, force_hw, restart_wdt)
#INT_SSP
void ssp_interrupt()
{
int8 state, ir;
state = i2c_isr_state();
if(state < 0x80)
{
ir = i2c_read();
if(ir==0)
{
output_high(pin_A0);
output_low(pin_A1);
output_low(pin_A2);
output_low(pin_A3);
output_low(pin_A4);
output_low(pin_A5);
output_b(0x00);
output_low(pin_C0);
output_low(pin_C1);
output_low(pin_C2);
}
if(ir==1)
{
output_low(pin_A0);
output_high(pin_A1);
output_low(pin_A2);
output_low(pin_A3);
output_low(pin_A4);
output_low(pin_A5);
output_b(0x00);
output_low(pin_C0);
output_low(pin_C1);
output_low(pin_C2);
}
if(ir==2)
{
output_low(pin_A0);
output_low(pin_A1);
output_high(pin_A2);
output_low(pin_A3);
output_low(pin_A4);
output_low(pin_A5);
output_b(0x00);
output_low(pin_C0);
output_low(pin_C1);
output_low(pin_C2);
}
if(ir==3)
{
output_low(pin_A0);
output_low(pin_A1);
output_low(pin_A2);
output_high(pin_A3);
output_low(pin_A4);
output_low(pin_A5);
output_b(0x00);
output_low(pin_C0);
output_low(pin_C1);
output_low(pin_C2);
}
if(ir==4)
{
output_low(pin_A0);
output_low(pin_A1);
output_low(pin_A2);
output_low(pin_A3);
output_high(pin_A4);
output_low(pin_A5);
output_b(0x00);
output_low(pin_C0);
output_low(pin_C1);
output_low(pin_C2);
}
if(ir==5)
{
output_low(pin_A0);
output_low(pin_A1);
output_low(pin_A2);
output_low(pin_A3);
output_low(pin_A4);
output_high(pin_A5);
output_b(0x00);
output_low(pin_C0);
output_low(pin_C1);
output_low(pin_C2);
}
if(ir==6)
{
output_low(pin_A0);
output_low(pin_A1);
output_low(pin_A2);
output_low(pin_A3);
output_low(pin_A4);
output_low(pin_A5);
output_b(0x00);
output_high(pin_B0);
output_low(pin_C0);
output_low(pin_C1);
output_low(pin_C2);
}
if(ir==7)
{
output_low(pin_A0);
output_low(pin_A1);
output_low(pin_A2);
output_low(pin_A3);
output_low(pin_A4);
output_low(pin_A5);
output_b(0x00);
output_high(pin_B1);
output_low(pin_C0);
output_low(pin_C1);
output_low(pin_C2);
}
if(ir==8)
{
output_low(pin_A0);
output_low(pin_A1);
output_low(pin_A2);
output_low(pin_A3);
output_low(pin_A4);
output_low(pin_A5);
output_b(0x00);
output_high(pin_B2);
output_low(pin_C0);
output_low(pin_C1);
output_low(pin_C2);
}
if(ir==9)
{
output_low(pin_A0);
output_low(pin_A1);
output_low(pin_A2);
output_low(pin_A3);
output_low(pin_A4);
output_low(pin_A5);
output_b(0x00);
output_high(pin_B3);
output_low(pin_C0);
output_low(pin_C1);
output_low(pin_C2);
}
if(ir==10)
{
output_low(pin_A0);
output_low(pin_A1);
output_low(pin_A2);
output_low(pin_A3);
output_low(pin_A4);
output_low(pin_A5);
output_b(0x00);
output_high(pin_B4);
output_low(pin_C0);
output_low(pin_C1);
output_low(pin_C2);
}
if(ir==11)
{
output_low(pin_A0);
output_low(pin_A1);
output_low(pin_A2);
output_low(pin_A3);
output_low(pin_A4);
output_low(pin_A5);
output_b(0x00);
output_high(pin_B5);
output_low(pin_C0);
output_low(pin_C1);
output_low(pin_C2);
}
if(ir==12)
{
output_low(pin_A0);
output_low(pin_A1);
output_low(pin_A2);
output_low(pin_A3);
output_low(pin_A4);
output_low(pin_A5);
output_b(0x00);
output_high(pin_B7);
output_low(pin_C0);
output_low(pin_C1);
output_low(pin_C2);
}
if(ir==13)
{
output_low(pin_A0);
output_low(pin_A1);
output_low(pin_A2);
output_low(pin_A3);
output_low(pin_A4);
output_low(pin_A5);
output_b(0x00);
output_high(pin_C0);
output_low(pin_C1);
output_low(pin_C2);
}
if(ir==14)
{
output_low(pin_A0);
output_low(pin_A1);
output_low(pin_A2);
output_low(pin_A3);
output_low(pin_A4);
output_low(pin_A5);
output_b(0x00);
output_low(pin_C0);
output_high(pin_C1);
output_low(pin_C2);
}
if(ir==15)
{
output_low(pin_A0);
output_low(pin_A1);
output_low(pin_A2);
output_low(pin_A3);
output_low(pin_A4);
output_low(pin_A5);
output_b(0x00);
output_low(pin_C0);
output_low(pin_C1);
output_high(pin_C2);
}
}
}
void main ()
{
delay_ms(50);
int8 SW=0x20;
if(input_state(pin_c5)==1)
SW+=2;
if(input_state(pin_c6)==1)
SW+=4;
if(input_state(pin_c7)==1)
SW+=8;
I2C_slaveaddr(SW);
enable_interrupts(INT_SSP);
enable_interrupts(GLOBAL);
while(1);
}
|
Receiver IR Code:
Code: |
#include <18F25K22.h>
#fuses hs,nowdt,put,noprotect
#use delay(crystal=20MHz,clock=20MHz)
#use i2c(SLAVE, SDA=PIN_C4, SCL=PIN_C3, force_hw, restart_wdt)
#INT_SSP
void ssp_interrupt()
{
int8 state, ir, data;
state = i2c_isr_state();
if(state < 0x80)
{
ir = i2c_read();
if(ir==0)
{
//Y0
output_low(pin_a0);
output_low(pin_a1);
output_low(pin_a2);
output_low(pin_a3);
if(input_state(pin_a0)==0 && input_state(pin_a1)==0 && input_state(pin_a2)==0 && input_state(pin_a3)==0)
{
if(input_state(pin_a4)==1)
data=1;
if(input_state(pin_a4)==0)
data=0;
}
}
if(ir==1)
{
//Y1
output_high(pin_a0);
output_low(pin_a1);
output_low(pin_a2);
output_low(pin_a3);
if(input_state(pin_a0)==1 && input_state(pin_a1)==0 && input_state(pin_a2)==0 && input_state(pin_a3)==0)
{
if(input_state(pin_a4)==1)
data=1;
if(input_state(pin_a4)==0)
data=0;
}
}
if(ir==2)
{
//Y2
output_low(pin_a0);
output_high(pin_a1);
output_low(pin_a2);
output_low(pin_a3);
if(input_state(pin_a0)==0 && input_state(pin_a1)==1 && input_state(pin_a2)==0 && input_state(pin_a3)==0)
{
if(input_state(pin_a4)==1)
data=1;
if(input_state(pin_a4)==0)
data=0;
}
}
if(ir==3)
{
//Y3
output_high(pin_a0);
output_high(pin_a1);
output_low(pin_a2);
output_low(pin_a3);
if(input_state(pin_a0)==1 && input_state(pin_a1)==1 && input_state(pin_a2)==0 && input_state(pin_a3)==0)
{
if(input_state(pin_a4)==1)
data=1;
if(input_state(pin_a4)==0)
data=0;
}
}
if(ir==4)
{
//Y4
output_low(pin_a0);
output_low(pin_a1);
output_high(pin_a2);
output_low(pin_a3);
if(input_state(pin_a0)==0 && input_state(pin_a1)==0 && input_state(pin_a2)==1 && input_state(pin_a3)==0)
{
if(input_state(pin_a4)==1)
data=1;
if(input_state(pin_a4)==0)
data=0;
}
}
if(ir==5)
{
//Y5
output_high(pin_a0);
output_low(pin_a1);
output_high(pin_a2);
output_low(pin_a3);
if(input_state(pin_a0)==1 && input_state(pin_a1)==0 && input_state(pin_a2)==1 && input_state(pin_a3)==0)
{
if(input_state(pin_a4)==1)
data=1;
if(input_state(pin_a4)==0)
data=0;
}
}
if(ir==6)
{
//Y6
output_low(pin_a0);
output_high(pin_a1);
output_high(pin_a2);
output_low(pin_a3);
if(input_state(pin_a0)==0 && input_state(pin_a1)==1 && input_state(pin_a2)==1 && input_state(pin_a3)==0)
{
if(input_state(pin_a4)==1)
data=1;
if(input_state(pin_a4)==0)
data=0;
}
}
if(ir==7)
{
//Y7
output_high(pin_a0);
output_high(pin_a1);
output_high(pin_a2);
output_low(pin_a3);
if(input_state(pin_a0)==1 && input_state(pin_a1)==1 && input_state(pin_a2)==1 && input_state(pin_a3)==0)
{
if(input_state(pin_a4)==1)
data=1;
if(input_state(pin_a4)==0)
data=0;
}
}
if(ir==8)
{
//Y8
output_low(pin_a0);
output_low(pin_a1);
output_low(pin_a2);
output_high(pin_a3);
if(input_state(pin_a0)==0 && input_state(pin_a1)==0 && input_state(pin_a2)==0 && input_state(pin_a3)==1)
{
if(input_state(pin_a4)==1)
data=1;
if(input_state(pin_a4)==0)
data=0;
}
}
if(ir==9)
{
//Y9
output_high(pin_a0);
output_low(pin_a1);
output_low(pin_a2);
output_high(pin_a3);
if(input_state(pin_a0)==1 && input_state(pin_a1)==0 && input_state(pin_a2)==0 && input_state(pin_a3)==1)
{
if(input_state(pin_a4)==1)
data=1;
if(input_state(pin_a4)==0)
data=0;
}
}
if(ir==10)
{
//Y10
output_low(pin_a0);
output_high(pin_a1);
output_low(pin_a2);
output_high(pin_a3);
if(input_state(pin_a0)==0 && input_state(pin_a1)==1 && input_state(pin_a2)==0 && input_state(pin_a3)==1)
{
if(input_state(pin_a4)==1)
data=1;
if(input_state(pin_a4)==0)
data=0;
}
}
if(ir==11)
{
//Y11
output_high(pin_a0);
output_high(pin_a1);
output_low(pin_a2);
output_high(pin_a3);
if(input_state(pin_a0)==1 && input_state(pin_a1)==1 && input_state(pin_a2)==0 && input_state(pin_a3)==1)
{
if(input_state(pin_a4)==1)
data=1;
if(input_state(pin_a4)==0)
data=0;
}
}
if(ir==12)
{
//Y12
output_low(pin_a0);
output_low(pin_a1);
output_high(pin_a2);
output_high(pin_a3);
if(input_state(pin_a0)==0 && input_state(pin_a1)==0 && input_state(pin_a2)==1 && input_state(pin_a3)==1)
{
if(input_state(pin_a4)==1)
data=1;
if(input_state(pin_a4)==0)
data=0;
}
}
if(ir==13)
{
//Y13
output_high(pin_a0);
output_low(pin_a1);
output_high(pin_a2);
output_high(pin_a3);
if(input_state(pin_a0)==1 && input_state(pin_a1)==0 && input_state(pin_a2)==1 && input_state(pin_a3)==1)
{
if(input_state(pin_a4)==1)
data=1;
if(input_state(pin_a4)==0)
data=0;
}
}
if(ir==14)
{
//Y14
output_low(pin_a0);
output_high(pin_a1);
output_high(pin_a2);
output_high(pin_a3);
if(input_state(pin_a0)==0 && input_state(pin_a1)==1 && input_state(pin_a2)==1 && input_state(pin_a3)==1)
{
if(input_state(pin_a4)==1)
data=1;
if(input_state(pin_a4)==0)
data=0;
}
}
if(ir==15)
{
//Y15
output_high(pin_a0);
output_high(pin_a1);
output_high(pin_a2);
output_high(pin_a3);
if(input_state(pin_a0)==1 && input_state(pin_a1)==1 && input_state(pin_a2)==1 && input_state(pin_a3)==1)
{
if(input_state(pin_a4)==1)
data=1;
if(input_state(pin_a4)==0)
data=0;
}
}
}
if(state >= 0x80)
{
i2c_write(data);
}
}
void main ()
{
delay_ms(50);
output_low(pin_a5);
int8 SW=0x10;
if(input_state(pin_c5)==1)
SW+=2;
if(input_state(pin_c6)==1)
SW+=4;
if(input_state(pin_c7)==1)
SW+=8;
I2C_slaveaddr(SW);
enable_interrupts(INT_SSP);
enable_interrupts(GLOBAL);
while(1);
}
|
I do not have any problems in modbus communication.
The library I use works correctly.
My problem is to turn on and off the reciprocal transceiver ir leds.
For example, if I turn off the 0.ir receiver led and the 4. receiver led at the same time, it will work correctly.
There is also no problem in i2c communication when i check. IR transmitter leds work in the correct order.
It works correctly when I test 3 transceiver ir LEDs.
But if I run more ir LEDs, I get an error.
As if their order is getting confused.
Transmitter circuit diagram:
https://i.ibb.co/rGH22Fg/verici.png
Receiver circuit diagram:
https://i.ibb.co/Pr10MVW/al-c.png
Last edited by emaxxenon on Thu Mar 12, 2020 4:11 am; edited 2 times in total |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19544
|
|
Posted: Thu Mar 12, 2020 3:18 am |
|
|
You need to get rid of the ISR code in the master.
I2C_ISR_STATE, is for a _slave_. The '0' condition that starts it, is an
address match (so the slave address being received). Similarly the 0x80
state is an address match with the R/W bit set. Again _for a slave_.
On the master _you_ initiate all transfers, so there is no ISR. and the state
won't work correctly.
Currently you will get interrupts when the receive buffer fills, but the
state will not be correct, and then the byte will be read in two places. In
the main that is actually triggering the transaction, and then in the ISR
again. Not how this needs to happen.
There is a requirement in I2C, of a pause between a stop, and the next start
this is 4.7uSec for standard mode and 1.3uSec for fast mode. You are not
putting any pause at all at this point. |
|
|
emaxxenon
Joined: 21 Jan 2020 Posts: 42
|
|
Posted: Thu Mar 12, 2020 3:24 am |
|
|
Ttelmah wrote: | You need to get rid of the ISR code in the master.
I2C_ISR_STATE, is for a _slave_. The '0' condition that starts it, is an
address match (so the slave address being received). Similarly the 0x80
state is an address match with the R/W bit set. Again _for a slave_.
On the master _you_ initiate all transfers, so there is no ISR. and the state
won't work correctly.
Currently you will get interrupts when the receive buffer fills, but the
state will not be correct, and then the byte will be read in two places. In
the main that is actually triggering the transaction, and then in the ISR
again. Not how this needs to happen.
There is a requirement in I2C, of a pause between a stop, and the next start
this is 4.7uSec for standard mode and 1.3uSec for fast mode. You are not
putting any pause at all at this point. |
I2C_ISR_STATE ;
I couldn't understand how to do this.
What code change should I make in master?
Thank you very much for your reply. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19544
|
|
Posted: Thu Mar 12, 2020 3:33 am |
|
|
You do not use I2C_ISR_STATE in a master.
The whole point is in a master _you_ initiate all transfers. There is no
interrupt use for something happening on the bus because things only
happen when _you_ do them.
Just take the byte value you are reading back in the loop and set your
LED's from this.
I'd suspect your big problem is the lack of delay between stop and any
subsequent start. This is the 'bus hold time'. Required, but most
simulators don't bother to check this. The real chips will though..... |
|
|
emaxxenon
Joined: 21 Jan 2020 Posts: 42
|
|
Posted: Thu Mar 12, 2020 4:14 am |
|
|
Ttelmah wrote: | You do not use I2C_ISR_STATE in a master.
The whole point is in a master _you_ initiate all transfers. There is no
interrupt use for something happening on the bus because things only
happen when _you_ do them.
Just take the byte value you are reading back in the loop and set your
LED's from this.
I'd suspect your big problem is the lack of delay between stop and any
subsequent start. This is the 'bus hold time'. Required, but most
simulators don't bother to check this. The real chips will though..... |
Code: |
#INT_SSP
void ssp_interrupt()
{
int8 state;
state = i2c_isr_state();
.
.
.
|
Are you saying I should add this to the main code?
What you mean, I couldn't understand. I'm sorry.
Is it possible to show what I should do with the code?
Thank you. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19544
|
|
Posted: Thu Mar 12, 2020 4:48 am |
|
|
You need to get rid of all your SSP ISR code in the master.
Ensure INT_SSP is disabled.
Then where you have:
data = i2c_read(0);
Use the value read here to control the LED's.
Then wherever you have i2c_stop(), add a line afterwards with
delay_us(2);
You never read from T_SLAVE1. Does this ever return anything?. If so
you need to add code to read this. |
|
|
emaxxenon
Joined: 21 Jan 2020 Posts: 42
|
|
Posted: Thu Mar 12, 2020 6:47 am |
|
|
Ttelmah wrote: | You need to get rid of all your SSP ISR code in the master.
Ensure INT_SSP is disabled.
Then where you have:
data = i2c_read(0);
Use the value read here to control the LED's.
Then wherever you have i2c_stop(), add a line afterwards with
delay_us(2);
You never read from T_SLAVE1. Does this ever return anything?. If so
you need to add code to read this. |
Code: | disable_interrupts(INT_SSP); |
I added this to the master.
i2c_stop() ; After that I added a wait. (delay_us(5))
My problem is that the receiver ir LEDs are jumping.
0. , 4. , 8. , 12. IR LED does not see.
But it works properly when I turn off all receiver IR LEDs.
I do not need to receive information from the transmitting IR LEDs. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19544
|
|
Posted: Thu Mar 12, 2020 6:59 am |
|
|
What resistors are you using on the LED's?.
Because you use 'input_state', if the LED pin does not go high enough top be
seen as a '1' the code will return the wrong value. So if the pins are
'overdriven', there will be issues. |
|
|
emaxxenon
Joined: 21 Jan 2020 Posts: 42
|
|
Posted: Thu Mar 12, 2020 7:08 am |
|
|
Ttelmah wrote: | What resistors are you using on the LED's?.
Because you use 'input_state', if the LED pin does not go high enough top be
seen as a '1' the code will return the wrong value. So if the pins are
'overdriven', there will be issues. |
Transmitter circuit diagram:
https://i.ibb.co/rGH22Fg/verici.png
Receiver circuit diagram:
https://i.ibb.co/Pr10MVW/al-c.png
10K resistor is applied in parallel to my transmitter ir leds. To go to the cut.
I think it shouldn't be a random jump. 0-4-8-12. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 12, 2020 8:32 am |
|
|
Here you define various slave addresses in the Master code:
Quote: | #define R_SLAVE1_W 0x10
#define R_SLAVE1_R 0x11
#define T_SLAVE1_W 0x20
#define T_SLAVE1_R 0x21
|
But in your slave code, you don't declare the slave addresses:
Quote: |
#use i2c(SLAVE, SDA=PIN_C4, SCL=PIN_C3, force_hw, restart_wdt) |
My compiler (vs. 5.093) gives me a warning for that line:
Quote: | >>> Warning 226 - Line 5(5,8): Option may be wrong. Address is reserved |
Let's be blunt. You're letting it default to address 0x00, the General Call
address. I doubt that's what you want. |
|
|
emaxxenon
Joined: 21 Jan 2020 Posts: 42
|
|
Posted: Thu Mar 12, 2020 8:59 am |
|
|
PCM programmer wrote: | Here you define various slave addresses in the Master code:
Quote: | #define R_SLAVE1_W 0x10
#define R_SLAVE1_R 0x11
#define T_SLAVE1_W 0x20
#define T_SLAVE1_R 0x21
|
But in your slave code, you don't declare the slave addresses:
Quote: |
#use i2c(SLAVE, SDA=PIN_C4, SCL=PIN_C3, force_hw, restart_wdt) |
My compiler (vs. 5.093) gives me a warning for that line:
Quote: | >>> Warning 226 - Line 5(5,8): Option may be wrong. Address is reserved |
Let's be blunt. You're letting it default to address 0x00, the General Call
address. I doubt that's what you want. |
Code: | int8 SW=0x20;
if(input_state(pin_c5)==1)
SW+=2;
if(input_state(pin_c6)==1)
SW+=4;
if(input_state(pin_c7)==1)
SW+=8;
I2C_slaveaddr(SW); |
I had defined the addresses like this.
I changed it this way.
Code: | #use i2c(SLAVE, SDA=PIN_C4, SCL=PIN_C3, force_hw, address=0x20, restart_wdt) |
the result has not changed.
0-4-8-12 cannot see the IR LED.
No problem when I test one by one.
But when they are all together, they do not see 1 in every 4. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|