more i2c and mcp23017


Closed Thread
Results 1 to 27 of 27

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: more i2c and mcp23017

    Deleted, reformulated with complete code in next post.
    Last edited by Demon; - 4th October 2024 at 04:59.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: more i2c and mcp23017

    I cleaned my code up, so it's really apparent what I'm trying to do.

    I still won't blink the 16 LEDs.

    Code:
    #CONFIG
        __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_ON
        __config _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON & _DEBUG_OFF
        __config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_OFF & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC
        __config _CONFIG4, _WRT_OFF & _SCANE_available & _LVP_OFF
        __config _CONFIG5, _CP_OFF & _CPD_OFF
    #ENDCONFIG
    
    DEFINE OSC 32
    
    define  CCP1_REG     0              ' Must clear unused CCP pins or else unpredictable results
    DEFINE  CCP1_BIT     0
    define  CCP2_REG     0
    DEFINE  CCP2_BIT     0
    DEFINE  CCP3_REG    PORTB
    DEFINE  CCP3_BIT     5
    define  CCP4_REG     0
    DEFINE  CCP4_BIT     0
    define  CCP5_REG     0
    DEFINE  CCP5_BIT     0
    
    ANSELA = %00000000
    ANSELB = %00000000
    ANSELC = %00000000
    ANSELD = %00000000
    ANSELE = %00000000
    
    TRISA = %00000000
    TRISB = %00000000
    TRISC = %00000000
    TRISD = %00000000
    TRISE = %00001000
    
    PinSCL2     VAR PortB.1
    PinSDA2     VAR PortB.2
    
        HPWM 3, 8, 1953
    
    addr        var byte : addr      = %01000000        ' $40
    
    IOCONreg    var byte : IOCONreg  = $05
    IOCONdat    var byte : IOCONdat  = %10110000
    '   bit 7   1 = The registers associated with each port are separated into different banks.
    '   bit 6   0 = The INT pins are not connected. INTA is associated with PORTA and INTB is associated with PORTB
    '   bit 5   1 = Sequential operation disabled, address pointer does not increment.
    '   bit 4   1 = Slew rate disabled
    '   bit 3   0 = Disables the MCP23S17 address pins.
    '   bit 2   0 = Active driver output (INTPOL bit sets the polarity.)
    '   bit 1   0 = Active-low
    '   bit 0   Unimplemented: Read as ‘0’
    
        I2CWRITE PinSDA2,PinSCL2,addr,IOCONreg,[IOCONdat]
    
    IODIRAreg   var byte : IODIRAreg = $00 
    IODIRAdat   var byte : IODIRAdat = %00000000
    
        I2CWRITE PinSDA2,PinSCL2,addr,IODIRAreg,[IODIRAdat] 'set GPIOA all output
    
    IODIRBreg   var byte : IODIRBreg = $10
    IODIRBdat   var byte : IODIRBdat = %00000000
    
        I2CWRITE PinSDA2,PinSCL2,addr,IODIRBreg,[IODIRBdat] 'set GPIOB all output
    
    GPIOAreg    var byte : GPIOAdat    var byte
    GPIOBreg    var byte : GPIOBdat    var byte
    
    LOOOP:
        GPIOAreg    = $09 : GPIOAdat    = %00000000
        I2CWRITE PinSDA2,PinSCL2,addr,GPIOAreg,[GPIOAdat]
    
        GPIOBreg    = $19 : GPIOBdat    = %00000000
        I2CWRITE PinSDA2,PinSCL2,addr,GPIOBreg,[GPIOBdat]
    
        pause 250
    
        GPIOAreg    = $09 : GPIOAdat    = %11111111
        I2CWRITE PinSDA2,PinSCL2,addr,GPIOAreg,[GPIOAdat]
    
        GPIOBreg    = $19 : GPIOBdat    = %11111111
        I2CWRITE PinSDA2,PinSCL2,addr,GPIOBreg,[GPIOBdat]
    
        pause 250
    
        GOTO LOOOP
    end

    The HPWM is for a IRFZ44N that i use to pulse the LED grounds. I have a simple LED on it to confirm that it's operating.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: more i2c and mcp23017

    Tried with OLAT registers, no joy.

    Code:
    #CONFIG
        __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_ON
        __config _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON & _DEBUG_OFF
        __config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_OFF & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC
        __config _CONFIG4, _WRT_OFF & _SCANE_available & _LVP_OFF
        __config _CONFIG5, _CP_OFF & _CPD_OFF
    #ENDCONFIG
    
    DEFINE OSC 32
    
    define  CCP1_REG     0              ' Must clear unused CCP pins or else unpredictable results
    DEFINE  CCP1_BIT     0
    define  CCP2_REG     0
    DEFINE  CCP2_BIT     0
    DEFINE  CCP3_REG    PORTB
    DEFINE  CCP3_BIT     5
    define  CCP4_REG     0
    DEFINE  CCP4_BIT     0
    define  CCP5_REG     0
    DEFINE  CCP5_BIT     0
    
    ANSELA = %00000000
    ANSELB = %00000000
    ANSELC = %00000000
    ANSELD = %00000000
    ANSELE = %00000000
    
    TRISA = %00000000
    TRISB = %00000000
    TRISC = %00000000
    TRISD = %00000000
    TRISE = %00001000
    
    PinSCL2     VAR PortB.1
    PinSDA2     VAR PortB.2
    
        HPWM 3, 8, 1953
    
    addr        var byte : addr      = %01000000        ' $40
    
    IOCONreg    var byte : IOCONreg  = $05
    IOCONdat    var byte : IOCONdat  = %10110000
    '   bit 7   1 = The registers associated with each port are separated into different banks.
    '   bit 6   0 = The INT pins are not connected. INTA is associated with PORTA and INTB is associated with PORTB
    '   bit 5   1 = Sequential operation disabled, address pointer does not increment.
    '   bit 4   1 = Slew rate disabled
    '   bit 3   0 = Disables the MCP23S17 address pins.
    '   bit 2   0 = Active driver output (INTPOL bit sets the polarity.)
    '   bit 1   0 = Active-low
    '   bit 0   Unimplemented: Read as ‘0’
    
        I2CWRITE PinSDA2,PinSCL2,addr,IOCONreg,[IOCONdat]
    
    IODIRAreg   var byte : IODIRAreg = $00 
    IODIRAdat   var byte : IODIRAdat = %00000000
    
        I2CWRITE PinSDA2,PinSCL2,addr,IODIRAreg,[IODIRAdat] 'set GPIOA all output
    
    IODIRBreg   var byte : IODIRBreg = $10
    IODIRBdat   var byte : IODIRBdat = %00000000
    
        I2CWRITE PinSDA2,PinSCL2,addr,IODIRBreg,[IODIRBdat] 'set GPIOB all output
    
    OLATAreg    var byte : OLATAdat    var byte
    OLATBreg    var byte : OLATBdat    var byte
    
    LOOOP:
        OLATAreg    = $0A : OLATAdat    = %00000000
        I2CWRITE PinSDA2,PinSCL2,addr,OLATAreg,[OLATAdat]
    
        OLATBreg    = $1A : OLATBdat    = %00000000
        I2CWRITE PinSDA2,PinSCL2,addr,OLATBreg,[OLATBdat]
    
        pause 250
    
        OLATAreg    = $0A : OLATAdat    = %11111111
        I2CWRITE PinSDA2,PinSCL2,addr,OLATAreg,[OLATAdat]
    
        OLATBreg    = $1A : OLATBdat    = %11111111
        I2CWRITE PinSDA2,PinSCL2,addr,OLATBreg,[OLATBdat]
    
        pause 250
    
        GOTO LOOOP
    end
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: more i2c and mcp23017

    It won't let me add info to my previous post above:

    16F18877
    MCP23017


    Using 1K/130pF on SCL/SDA as mentioned on p.5 of datasheet (they use 135pF).
    Last edited by Demon; - 4th October 2024 at 05:16.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: more i2c and mcp23017

    I didn't quite understand what they meant with the Bank A/B at first.

    I've now tried with both versions, and still no blinky.

    Code:
    #CONFIG
        __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_ON
        __config _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON & _DEBUG_OFF
        __config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_OFF & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC
        __config _CONFIG4, _WRT_OFF & _SCANE_available & _LVP_OFF
        __config _CONFIG5, _CP_OFF & _CPD_OFF
    #ENDCONFIG
    
    DEFINE OSC 32
    
    define  CCP1_REG     0              ' Must clear unused CCP pins or else unpredictable results
    DEFINE  CCP1_BIT     0
    define  CCP2_REG     0
    DEFINE  CCP2_BIT     0
    DEFINE  CCP3_REG    PORTB
    DEFINE  CCP3_BIT     5
    define  CCP4_REG     0
    DEFINE  CCP4_BIT     0
    define  CCP5_REG     0
    DEFINE  CCP5_BIT     0
    
    ANSELA = %00000000
    ANSELB = %00000000
    ANSELC = %00000000
    ANSELD = %00000000
    ANSELE = %00000000
    
    TRISA = %00000000
    TRISB = %00000000
    TRISC = %00000000
    TRISD = %00000000
    TRISE = %00001000
    
    PinSCL2     VAR PortB.1
    PinSDA2     VAR PortB.2
    
        HPWM 3, 8, 1953
    
    addr        var byte : addr      = %01000000        ' $40
    
    IOCONreg    var byte : IOCONreg  = $05
    IOCONdat    var byte : IOCONdat  = %00110000      ' Bank=0
    'IOCONdat    var byte : IOCONdat  = %10110000      ' Bank=1
    '   bit 7   1 = The registers associated with each port are separated into different banks.
    '   bit 6   0 = The INT pins are not connected. INTA is associated with PORTA and INTB is associated with PORTB
    '   bit 5   1 = Sequential operation disabled, address pointer does not increment.
    '   bit 4   1 = Slew rate disabled
    '   bit 3   0 = Disables the MCP23S17 address pins.
    '   bit 2   0 = Active driver output (INTPOL bit sets the polarity.)
    '   bit 1   0 = Active-low
    '   bit 0   Unimplemented: Read as ‘0’
    
        I2CWRITE PinSDA2,PinSCL2,addr,IOCONreg,[IOCONdat] : pauseus 1
    
    IODIRAreg   var byte : IODIRAreg = $00      ' Bank=0 
    'IODIRAreg   var byte : IODIRAreg = $00      ' Bank=1  
    IODIRAdat   var byte : IODIRAdat = %00000000
    
        I2CWRITE PinSDA2,PinSCL2,addr,IODIRAreg,[IODIRAdat] : pauseus 1 'set GPIOA all output
    
    IODIRBreg   var byte : IODIRBreg = $01      ' Bank=0 
    'IODIRBreg   var byte : IODIRBreg = $10      ' Bank=1 
    IODIRBdat   var byte : IODIRBdat = %00000000
    
        I2CWRITE PinSDA2,PinSCL2,addr,IODIRBreg,[IODIRBdat] : pauseus 1 'set GPIOB all output
    
    OLATAreg    var byte : OLATAdat    var byte
    OLATBreg    var byte : OLATBdat    var byte
    
    LOOOP:
        OLATAreg    = $14 : OLATAdat    = %00000000      ' Bank=0
    '    OLATAreg    = $0A : OLATAdat    = %00000000      ' Bank=1
        I2CWRITE PinSDA2,PinSCL2,addr,OLATAreg,[OLATAdat] : pauseus 1
    
        OLATBreg    = $15 : OLATBdat    = %00000000      ' Bank=0
    '    OLATBreg    = $1A : OLATBdat    = %00000000      ' Bank=1
        I2CWRITE PinSDA2,PinSCL2,addr,OLATBreg,[OLATBdat] : pauseus 1
    
        pause 250
    
        OLATAreg    = $14 : OLATAdat    = %11111111      ' Bank=0
    '    OLATAreg    = $0A : OLATAdat    = %11111111      ' Bank=1
        I2CWRITE PinSDA2,PinSCL2,addr,OLATAreg,[OLATAdat] : pauseus 1
    
        OLATBreg    = $15 : OLATBdat    = %11111111      ' Bank=0
    '    OLATBreg    = $1A : OLATBdat    = %11111111      ' Bank=1
        I2CWRITE PinSDA2,PinSCL2,addr,OLATBreg,[OLATBdat] : pauseus 1
    
        pause 250
    
        GOTO LOOOP
    end
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: more i2c and mcp23017

    Argh, won't let me add a comment.

    Apparently I still hadn't understood how I'm supposed to set the register for IOCON.

    Latest attempt, still no workie.

    Code:
    #CONFIG
        __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_ON
        __config _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON & _DEBUG_OFF
        __config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_OFF & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC
        __config _CONFIG4, _WRT_OFF & _SCANE_available & _LVP_OFF
        __config _CONFIG5, _CP_OFF & _CPD_OFF
    #ENDCONFIG
    
    DEFINE OSC 32
    
    define  CCP1_REG     0              ' Must clear unused CCP pins or else unpredictable results
    DEFINE  CCP1_BIT     0
    define  CCP2_REG     0
    DEFINE  CCP2_BIT     0
    DEFINE  CCP3_REG    PORTB
    DEFINE  CCP3_BIT     5
    define  CCP4_REG     0
    DEFINE  CCP4_BIT     0
    define  CCP5_REG     0
    DEFINE  CCP5_BIT     0
    
    ANSELA = %00000000
    ANSELB = %00000000
    ANSELC = %00000000
    ANSELD = %00000000
    ANSELE = %00000000
    
    TRISA = %00000000
    TRISB = %00000000
    TRISC = %00000000
    TRISD = %00000000
    TRISE = %00001000
    
    PinSCL2     VAR PortB.1
    PinSDA2     VAR PortB.2
    
        HPWM 3, 8, 1953
    
    addr        var byte : addr      = %01000000        ' $40
    
    IOCONAreg    var byte : IOCONAreg  = $0A        ' Bank=0
    IOCONBreg    var byte : IOCONBreg  = $0B        ' Bank=0
    IOCONdat    var byte : IOCONdat  = %00110000    ' Bank=0
    'IOCONAreg    var byte : IOCONAreg  = $05        ' Bank=1
    'IOCONBreg    var byte : IOCONBreg  = $15        ' Bank=1
    'IOCONdat    var byte : IOCONdat  = %10110000    ' Bank=1
    '   bit 7   0 = The registers associated with each port are separated into different banks.
    '   bit 6   0 = The INT pins are not connected. INTA is associated with PORTA and INTB is associated with PORTB
    '   bit 5   1 = Sequential operation disabled, address pointer does not increment.
    '   bit 4   1 = Slew rate disabled
    '   bit 3   0 = Disables the MCP23S17 address pins.
    '   bit 2   0 = Active driver output (INTPOL bit sets the polarity.)
    '   bit 1   0 = Active-low
    '   bit 0   Unimplemented: Read as ‘0’
    
        I2CWRITE PinSDA2,PinSCL2,addr,IOCONAreg,[IOCONdat]
        I2CWRITE PinSDA2,PinSCL2,addr,IOCONBreg,[IOCONdat]
    
    IODIRAreg   var byte : IODIRAreg = $00      ' Bank=0 
    'IODIRAreg   var byte : IODIRAreg = $00      ' Bank=1  
    IODIRAdat   var byte : IODIRAdat = %00000000
    
        I2CWRITE PinSDA2,PinSCL2,addr,IODIRAreg,[IODIRAdat] 'set GPIOA all output
    
    IODIRBreg   var byte : IODIRBreg = $01      ' Bank=0 
    'IODIRBreg   var byte : IODIRBreg = $10      ' Bank=1 
    IODIRBdat   var byte : IODIRBdat = %00000000
    
        I2CWRITE PinSDA2,PinSCL2,addr,IODIRBreg,[IODIRBdat] 'set GPIOB all output
    
    OLATAreg    var byte : OLATAdat    var byte
    OLATBreg    var byte : OLATBdat    var byte
    
    LOOOP:
        OLATAreg    = $14 : OLATAdat    = %00000000      ' Bank=0
    '    OLATAreg    = $0A : OLATAdat    = %00000000      ' Bank=1
        I2CWRITE PinSDA2,PinSCL2,addr,OLATAreg,[OLATAdat]
    
        OLATBreg    = $15 : OLATBdat    = %00000000      ' Bank=0
    '    OLATBreg    = $1A : OLATBdat    = %00000000      ' Bank=1
        I2CWRITE PinSDA2,PinSCL2,addr,OLATBreg,[OLATBdat]
    
        pause 250
    
        OLATAreg    = $14 : OLATAdat    = %11111111      ' Bank=0
    '    OLATAreg    = $0A : OLATAdat    = %11111111      ' Bank=1
        I2CWRITE PinSDA2,PinSCL2,addr,OLATAreg,[OLATAdat]
    
        OLATBreg    = $15 : OLATBdat    = %11111111      ' Bank=0
    '    OLATBreg    = $1A : OLATBdat    = %11111111      ' Bank=1
        I2CWRITE PinSDA2,PinSCL2,addr,OLATBreg,[OLATBdat]
    
        pause 250
    
        GOTO LOOOP
    end
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  7. #7
    Join Date
    Aug 2011
    Posts
    457


    Did you find this post helpful? Yes | No

    Default Re: more i2c and mcp23017

    For the MCP23017 28-pin DIP package make sure you have connections to:
    RESETn (pin 18)
    A2, A1, A0 (pins 17, 16, 15) - these should be pulled low (GND) for address $40... they should not be left floating

    There should also be pullups to VDD on SCL (pin 12) and SDA (pin 13)

  8. #8
    Join Date
    May 2013
    Location
    australia
    Posts
    2,680


    Did you find this post helpful? Yes | No

    Default Re: more i2c and mcp23017

    The example you refer to used and expected iocon.bank to = 1 , why i chose that and how it got that way are lost into the mystery of time. [probably some weird dev board]
    this simulates ok for bank=0

    Code:
    #CONFIG    __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_ON
        __config _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON & _DEBUG_OFF
        __config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_ON & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC
        __config _CONFIG4, _WRT_OFF & _SCANE_available & _LVP_ON
        __config _CONFIG5, _CP_OFF & _CPD_OFF
    #ENDCONFIG
    
    
    DEFINE OSC 32
    ANSELB = 0
    PinSCL2     VAR PortB.1
    PinSDA2     VAR PortB.2
    GPIOAdat    var byte
    GPIOBdat    var byte
    addr        var byte 
    reg   var byte 
    dat   var byte 
    
    
    addr      = %01000000        ' $40
    
    
    ; UNCOMMENT EITHER SECTION BANK=0 OR BANK=1     NOT BOTH
    
    
    
    
    
    
    ;START IOCON.BANK=0
    
    
    reg = 0
    dat = 0
    
    
    I2CWRITE PinSDA2,PinSCL2,addr,reg,[dat] 'set GPIOA all output
    
    
    reg = 1
    dat = 0
    
    
    I2CWRITE PinSDA2,PinSCL2,addr,reg,[dat] 'set GPIOB all output
    
    
    
    
    
    
    LOOOP:
        reg    = $12 : GPIOAdat    = %00000000
        I2CWRITE PinSDA2,PinSCL2,addr,reg,[GPIOAdat]
    
    
        reg    = $13      : GPIOBdat    = %00000000
        I2CWRITE PinSDA2,PinSCL2,addr,reg,[GPIOBdat]
    
    
        pause 250
    
    
        reg    = $12 : GPIOAdat    = %11111111
        I2CWRITE PinSDA2,PinSCL2,addr,reg,[GPIOAdat]
    
    
        reg    = $13 : GPIOBdat    = %11111111
        I2CWRITE PinSDA2,PinSCL2,addr,reg,[GPIOBdat]
    
    
        pause 250
    
    
        GOTO LOOOP
    end   ;IOCON.BANK=0
    
    
    
    
    
    
    
    
     ;START IOCON.BANK=1  ; NOT TESTED BANK=1 NOT SUPPORTED IN SIMULATOR
    'reg = $A
    'dat = %10100000
    'I2CWRITE PinSDA2,PinSCL2,addr,reg,[dat]
    
    
     
    'reg = 0
    'dat = 0
    
    
    'I2CWRITE PinSDA2,PinSCL2,addr,reg,[dat] 'set GPIOA all output
    
    
    'reg = $10
    'dat = 0
    
    
    'I2CWRITE PinSDA2,PinSCL2,addr,reg,[dat] 'set GPIOB all output
    
    
    
    
    
    
    'LOOOP:
    '    reg    = $9 : GPIOAdat    = %00000000
    '    I2CWRITE PinSDA2,PinSCL2,addr,reg,[GPIOAdat]
    
    
    '    reg    = $19      : GPIOBdat    = %00000000
    '    I2CWRITE PinSDA2,PinSCL2,addr,reg,[GPIOBdat]
    
    
    '    pause 250
    
    
    '    reg    = $9 : GPIOAdat    = %11111111
    '    I2CWRITE PinSDA2,PinSCL2,addr,reg,[GPIOAdat]
    
    
    '    reg    = $19 : GPIOBdat    = %11111111
    '    I2CWRITE PinSDA2,PinSCL2,addr,reg,[GPIOBdat]
    
    
    '    pause 250
    
    
    '    GOTO LOOOP
    'end     ;IOCON.BANK=1
    Warning I'm not a teacher

Similar Threads

  1. need help with PBP, I2C and MCP23017
    By queenidog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 20th May 2018, 00:01
  2. I2C two master on one I2C display
    By Kmt in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd September 2014, 20:44
  3. I2C question w/ MCP23017 Port Expanders
    By dsicon in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th December 2012, 05:47
  4. PIC 18F4550 and MCP23017
    By DaveC3 in forum Code Examples
    Replies: 12
    Last Post: - 4th December 2010, 14:01
  5. I2C, little help please
    By gluphus in forum Serial
    Replies: 2
    Last Post: - 15th March 2006, 04:32

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