I/O extender


Results 1 to 18 of 18

Thread: I/O extender

Threaded View

  1. #8
    Join Date
    Jun 2006
    Posts
    40


    Did you find this post helpful? Yes | No

    Default

    I took longer time to try out with MCP23016 because i am still using shift register to expand the I/O. Last week i decided to try out MCP23016. However it doesn't work, after few days trial & error and change the address, i almost give up. Not sure what happen. either the code or the IC faulty because i only have one piece.

    Can someone advice ?
    Appreciate that.


    'MASTER CODE
    'This test is to check output functionality ( LED ) - Running LED
    'MCP23016 connected to address 0

    INCLUDE "modedefs.bas"


    '*****PORT Setup********************************************* *****************
    GreenLED VAR PORTA.0'O Indicator Green
    SDA VAR PORTA.1 'O Serial Data
    SCL VAR PORTA.2 'O Serial Clock
    RedLED VAR PORTA.3 'O Indicator Red

    '*****Constant************************************ ****************************
    CtrlRW1 CON 00 'Access to Set1 GP0
    CtrlRW2 CON 01 'Access to Set2 GP1
    CtrlDir1 CON 06 'Access to Set1 IODIR/0
    CtrlDir2 CON 07 'Access to Set2 IODIR/1


    '**VARIABLES************************************** ****************************
    Address VAR BYTE 'Address size
    Set1 VAR BYTE 'Place to put Data Set1
    Set2 VAR BYTE 'Place to put Data Set2

    Address=0 'Select MCP23016 address as 0

    Set1=0 'Clear Set1
    Set2=0 'Clear Set2


    '*****INITIALIZING MCP23016 All as Output**************************************
    I2CWrite SDA,SCL,CtrlDir1,Address,[00] 'Set as Output
    Pause 10 'Delay 10ms
    I2CWrite SDA,SCL,CtrlDir2,Address,[00] 'Set as Output
    Pause 10 'Delay 10ms


    Start :
    Set1=$FF 'To turn on all LEDs connected to Set1
    Set2=$FF 'TO turn ON all LEDs connected TO Set2

    I2CWrite SDA,SCL,CtrlRW1,Address,[Set1] 'Turn on the LEDs
    Pause 10 'Wait 10ms

    I2CWrite SDA,SCL,CtrlRW2,Address,[Set2] 'Turn on the LEDs
    Pause 10 'Wait 10ms


    GoTo Start
    Attached Images Attached Images
    Cheers,

    mychangl
    "The Dream Is Everything"

Similar Threads

  1. PORTA Logic - Be the processor
    By Darrel Taylor in forum FAQ - Frequently Asked Questions
    Replies: 29
    Last Post: - 9th March 2009, 18:18
  2. I/O dilemma
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 6th January 2008, 16:45
  3. MCP23016 I2C serial I/O expander chip
    By GeoJoe in forum Serial
    Replies: 7
    Last Post: - 31st October 2007, 15:39
  4. 16F877 universal PCB with I/O module
    By cupajoe in forum Schematics
    Replies: 12
    Last Post: - 3rd September 2005, 13:39
  5. managing the I/O ports of the 16F84A
    By skyler_91600 in forum mel PIC BASIC
    Replies: 7
    Last Post: - 28th April 2005, 03:52

Members who have read this thread : 0

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