Efi gazarov
Efi gazarov

Reputation: 171

Arduino MCP3008 library (spi) + LiquidTWI2 Library (i2c) hanging

I have arduino uno hanging when using MCP3008 (MCP3008 spi) and LiquidTWI2 (mcp23017 i2c) simultaneously . I can test both libraries alone and they are working fine,but not together.

I know that it freezes after first instantiation of MCP3008 next line using LiquidTWI2 will hang on Wire.endTransmission();

This is my example that hangs after last line of loop function (actually it hangs on second iteration lcd.setCursor)

  #include <Wire.h>
    #include <LiquidTWI2.h>
    #include <MCP3008.h>
    const int  _CS_PIN2 =9;
    const int  _CS_PIN =10;
    const int  _CLOCK_PIN= 13;
    const int  _MOSI_PIN= 11;
    const int  _MISO_PIN= 12;


    LiquidTWI2 lcd(0x20);

    void setup() {
      lcd.setMCPType(LTI_TYPE_MCP23017); 
      lcd.begin(16, 2);
      lcd.print("hello, world!");
    }

    void loop() {
      lcd.setCursor(0, 1); //freeze on second iteration
      lcd.print(millis()/1000);
      MCP3008  adc2(_CLOCK_PIN, _MOSI_PIN, _MISO_PIN, _CS_PIN2);
     }

Any help would be appreciated.

Upvotes: 1

Views: 386

Answers (1)

Efi gazarov
Efi gazarov

Reputation: 171

Sorry folks , it was short circuiting leg that caused the faulty situation. I can assure you now that both libraries are working together and not interfiering each other.

Details of the problem: The CS leg of MCP3008 was shorting to VDD line. In this state, after pinMode(_CSPIN,OUTPUT); statement in MCP3008 constructor, the Wire.endTransmission() on LiquidTWI2 will hang.

Upvotes: 0

Related Questions