PIC 18F4550 and MCP23017


Results 1 to 13 of 13

Threaded View

  1. #6
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    I think you have a typo error

    GPINTENA con &00 should be GPINTENA con $00

    Try that

    Dave

    You also need to initialize the MCP23017
    Code:
    InitMPC23017:
    Pause 100
    '#############  PORTA
    i2cwrite  PortA.0,PortA.1,IO_EXP0WR,[IOCONA,IOCONSETA]
    i2cwrite  PortA.0,PortA.1,IO_EXP0WR,[IODIRA,$0]          'PortA inputs
    i2cwrite  PortA.0,PortA.1,IO_EXP0WR,[IOLATA,$FF]            'PortA = 0
    'i2cwrite  PortA.0,PortA.1,IO_EXP0WR,[IPOLA,0]
    'i2cwrite  PortA.0,PortA.1,IO_EXP0WR,[DEFVALA,0]
    'i2cwrite  PortA.0,PortA.1,IO_EXP0WR,[GPPUA,$FF]           'pull-ups enabled
    'i2cwrite  PortA.0,PortA.1,IO_EXP0WR,[INTCONA,0]
    'i2cwrite  PortA.0,PortA.1,IO_EXP0WR,[GPINTENA,$FF]        'interupt on change
    '##############  PORTB
    i2cwrite  PortA.0,PortA.1,IO_EXP0WR,[IOCONB,IOCONSETB]
    i2cwrite  PortA.0,PortA.1,IO_EXP0WR,[IODIRB,0]
    i2cwrite  PortA.0,PortA.1,IO_EXP0WR,[IOLATB,$FF]
    'i2cwrite  PortA.0,PortA.1,IO_EXP0WR,[IPOLB,0]
    'i2cwrite  PortA.0,PortA.1,IO_EXP0WR,[DEFVALB,0]
    'i2cwrite  PortA.0,PortA.1,IO_EXP0WR,[INTCONB,0]
    'i2cwrite  PortA.0,PortA.1,IO_EXP0WR,[GPINTENB,0]
    return
    ReInitPortA:
    i2cwrite  PortA.0,PortA.1,IO_EXP0WR,[IOCONA,IOCONSETA]
    i2cwrite  PortA.0,PortA.1,IO_EXP0WR,[IODIRA,$FF] 
    i2cwrite  PortA.0,PortA.1,IO_EXP0WR,[GPPUA,$FF]           'pull-ups enabled
    
    return
    Last edited by ScaleRobotics; - 27th November 2010 at 16:11. Reason: changed [code end] typo

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts