MCP23017 init & data transfer

ChibiOS public support forum for topics related to the Freescale Kinetis family of micro-controllers.

Moderator: utzig

ravnicas
Posts: 1
Joined: Mon Jan 22, 2018 10:10 pm

MCP23017 init & data transfer

Postby ravnicas » Mon Jan 22, 2018 10:19 pm

hi, im hoping to find some help with i2c init on a teensy 3.2. I tried searching, but couldnt find the source of my problem.

Im trying to init an MCP23017 expander. The controller halts as soon as i start the data transfer. the goal is to set GPIOA1 to HIGH.
Maybe someone already had this problem, or could guide me to an answer. That would really help me.

Code: Select all

uint8_t init_mcp23017(void) {
    mcp23017_status = 0x20;

    palSetPadMode(TEENSY_PIN18_IOPORT, TEENSY_PIN18, PAL_MODE_OUTPUT_OPENDRAIN);
    palSetPadMode(TEENSY_PIN19_IOPORT, TEENSY_PIN19, PAL_MODE_OUTPUT_OPENDRAIN);
   
    i2cStart(&I2CD1, &i2ccfg);

    tx[0] = 0;
    tx[1] = 0;
   
    //i2cAcquireBus(&I2CD1);

    i2cMasterTransmitTimeout(&I2CD1, 32, tx, 2, rx, 0, 100);
   
   tx[0] = 20;
   tx[1] = 1;
   i2cMasterTransmitTimeout(&I2CD1, 32, tx, 2, rx, 0, 100);

    return mcp23017_status;
    }

wiml
Posts: 7
Joined: Fri Dec 08, 2017 6:52 am
Location: Seattle, USA
Has thanked: 2 times
Been thanked: 5 times

Re: MCP23017 init & data transfer

Postby wiml » Thu Feb 08, 2018 8:57 am

Do you have a pullup on the i2c lines? On the Kinetis parts, if you need a pullup but don't have an external pullup, I think you need to explicitly enable pullups on an open-drain pin (I don't think the PAL driver can do this, you need to do it explicitly). The i2c peripheral might be hanging because it interprets a low clock line as i2c "clock stretching".


Return to “Kinetis Support”

Who is online

Users browsing this forum: No registered users and 1 guest