I/O extender


Results 1 to 18 of 18

Thread: I/O extender

Threaded View

  1. #12
    Join Date
    Jun 2006
    Posts
    40


    Did you find this post helpful? Yes | No

    Exclamation Please clarify...

    Thanks, i'll try MCP23017.

    I know what going on wrong with the code...

    3 things been observed :
    1. I do not put "$" to determine the address in HEX
    2. Before initializing MCP23016, it need to have short delay ( i use 50ms ) otherwise the whole program will not work.
    3. The code should be I2CWrite SDA,SCL,Address,CtrlDir1,[00] not I2CWrite SDA,SCL,CtrlDir1,Address,[00]. This is confusing because the manual shows the address come after Control, but it does not work.

    It works fine after the correction.



    I need help to evaluate my second code.
    I use GP1 as input and GP0 as output.

    However this is what happened :

    Input Triggered | Output Respond
    ----------------+-----------------
    GP1.0 | No Respond
    GP1.1 | GP0.0
    GP1.2 | GP0.1
    GP1.3 | GP0.2
    GP1.4 | GP0.3
    GP1.5 | GP0.4
    GP1.6 | GP0.5
    GP1.7 | GP0.6

    GP0.7 never respond at all.

    Anyone can help ?



    Code:
     INCLUDE "modedefs.bas"
    
    '*****STARTUP*****************************************************************
    TRISA=%00000
    TRISB=%00000000
    
    '*****PORT Setup**************************************************************
    SDA VAR PORTA.1		'O Serial Data
    SCL VAR PORTA.2		'O Serial Clock
    
    '*****Constant****************************************************************
    CtrlRW1 CON 00	'Set1
    CtrlRW2 CON 01	'Set2
    CtrlDir1 CON 06	'Set1
    CtrlDir2 CON 07	'Set2
    
    	
    '**VARIABLES******************************************************************
    Address VAR BYTE	'Address size 
    Set VAR BYTE		'Temporary place to put Data
    
    Address=$40			'Set MCP23016 address as 01
    Set=$00				'Clear Temporary Storage
    
    
    '*****INITIALIZING MCP23016 **************************************************
    	Pause 50
    	I2CWrite SDA,SCL,Address,CtrlDir1,[00]	'Set as Output
    	Pause 10								'Delay 10ms
    	I2CWrite SDA,SCL,Address,CtrlDir2,[$FF]	'Set as Input
    	Pause 10								'Delay 10ms
    
    Start :
    	I2CRead SDA,SCL,Address,CtrlRW2,[Set]	'Read from input, put in Set
    	Pause 10								'Delay 10ms
    	
    	I2CWrite SDA,SCL,Address,CtrlRW1,[Set]	'Write data into Set
    	Pause 10 								'Delay 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