Hi,
I have project with using LPC1768 the control the multiple IoExpander.
I use 3 IoExpanders in my project .
In these conditions while ı was controlling the IoExpander my expander sometimes Even though I pull the line to 1, it pulls to 0 line.It is problem for my project.
I have shared the io expander part of the code I run my project below, if necessary, I can share the rest.
I’m using the i2c protocol for communicate the IoExpander.
void IoExpander()
{
Expander1 = new MCP23017( p9, p10, 0x42); //Initiliaze MCP23017
Expander2 = new MCP23017( p9, p10, 0x40);
Expander3 = new MCP23017( p9, p10, 0x44);
Expander1->config(0,0,0);
Expander2->config(0,0,0);
Expander3->config(0,0,0);
Expander1->write_bit(0,15);
Expander1->write_bit(1,6); //System Power Led
//Fault Reset and Remotes
if(Fault_Reset == true) {
Expander2->write_bit(0,7);
} else {
Expander2->write_bit(1,7);
}
if (G == true) {
Expander2->write_bit(0,6);
} else {
Expander2->write_bit(1,6);
}
if(F == true) {
Expander2->write_bit(0,5);
} else {
Expander2->write_bit(1,5);
}
if (C == true) {
Expander2->write_bit(0,4);
} else {
Expander2->write_bit(1,4);
}
Fault_AD1 = Expander2->read_bit(8);
Fault_AD2 = Expander2->read_bit(9);
Fault_AD3 = Expander2->read_bit(10);
Fault_AD4 = Expander2->read_bit(11);
Fault_AD5 = Expander2->read_bit(12);
Fault_AD6 = Expander2->read_bit(13);
Expander2->write_bit(0,0); // Rsv Faults Sets Low
Expander2->write_bit(0,1); // RSV_FLT5
Expander2->write_bit(0,2); //RSV_FLT4
Expander2->write_bit(0,3); //RSV_FLT3
//Exp1 Reserve
Expander1->write_bit(0,0); //Warning Led
Expander1->write_bit(0,2); //Caution
Expander1->write_bit(0,4); //SysDOWN
Expander1->write_bit(0,12);
Expander1->write_bit(0,13);
Expander1->write_bit(0,14);
//Exp3 Reserve
for (y = 0; y < 16; y++) {
Expander3->write_bit(1,y);
}
//For String Manipulation
if (Fault_AD1 == true ) { //
FAD1="T";
} else {
FAD1="F";
}
Fault_AD2 = Expander2->read_bit(9);
if (Fault_AD2 == true ) {
FAD2="T";
} else {
FAD2="F";
}
Fault_AD3 = Expander2->read_bit(10);
if (Fault_AD3 == true ) {
FAD3="T";
} else {
FAD3="F";
}
Fault_AD4 = Expander2->read_bit(11);
if (Fault_AD4 == true ) {
FAD4="T";
} else {
FAD4="F";
}
Fault_AD5 = Expander2->read_bit(12);
if (Fault_AD5 == true ) {
FAD5="T";
} else {
FAD5="F";
}
Fault_AD6 = Expander2->read_bit(13);
if (Fault_AD6 == true ) {
FAD6="T";
} else {
FAD6="F";
}
if( Connection_Info == true) {
Expander1->write_bit(1,5);
} else {
}
if ( Fault_AD1 == false || Fault_AD2 == false || Fault_AD3 == false || Fault_AD4 == false || Fault_AD5 == false || Fault_AD6 == false) { //Fault Detection
Expander1->write_bit(1,1);
MasterFault="F";
} else {
Expander1->write_bit(0,1);
MasterFault="T";
}
if ( C == true || G == true || F == true ) { //Manual Detection
Expander1->write_bit(1,3);
} else {
Expander1->write_bit(0,3);
}
delete Expander1; // Pointers causes memory leak we use for that
delete Expander2;
delete Expander3;
}
int main()
{
while(true) {
Led1 = !Led1;
IoExpander();
}
I’m using delete function for
I’m using for the library ;MCP23017 - Reset causes problems solved | Mbed
In this library I disabled the reset function in initialize for the resetting causes problems.
How can I block the MCP23017 pull to 0 zero when ı was set the 1 .