PIC 18F4550 and MCP23017


Results 1 to 13 of 13

Threaded View

  1. #3
    Join Date
    Nov 2010
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Hey Dave,
    Im trying to use 16f877a with macp23017, but I wasn't successful.
    I define the mcp23017 register, but when I want to compile my program it gives me error.
    I tried to use your program and learn from it but I had no success, I noticed you are using some include file that I dont have them.
    I have 16 led on each port would you please help me?

    Code:
    '*  Notes   :  XT 4Mhz                                          *
    '*          :                                                   *
    '****************************************************************
    'Includes 
    include "modedefs.bas" 
    '****************************************************************
    'Definitions
    DEFINE I2C_SDA PORTc,4 
    DEFINE I2C_SCL PORTc,3   
    '****************************************************************
    'Variables
    a var byte
    chip1 var byte
    chip2 var byte
    chip3 var byte
    chip4 var byte         
    '****************************************************************
    'Alias
    CP VAR PORTc.3
    DP VAR PORTc.4
                             
    '****************************************************************
    'Initialization
    
        'Pic 16f877A
    option_reg.7 = 0 'portb pullups enabled         
    SSPSTAT=%00111101
    'SSPCON1=%00101111
    SSPCON2=%00000001
    
        'MCP 23017
    
    IODIRA Con $00
    IODIRB con $00
    IPOLA con $00
    IPOLB con $00
    GPINTENA con &00
    GPINTENB con $00
    DEFVALA con $00
    DEFVALB con $00
    INTCONA con &00
    INTCONB con &FF
    IOCON con %00001000
    GPPUA con $00
    GPPUB con $00
    INTFA con $00
    INTFB con $00
    INTCAPA con &00
    INTCAPB con &00
    GPIOA con $00
    GPIOB Con $FF
    OLATA con $00
    OLATB con &FF  
    
    '****************************************************************
    'set ports   
         trisa=%00000000             
         trisc=%00000000     
         pause 500                 
         goto start          
    start:
        porta.5 = 1
        portc.7=0
        pause 500
        porta.5 = 1
        portc.7=1
        pause 500
        I2CWRITE dp,cp,$00,chip1,[%00000000] 'one-shot sample
        pause 200
        I2CWRITE dp,cp,$00,chip1,[%11111111] 'one-shot sample 
        pause 200
        I2CWRITE dp,cp,$00,chip1,[%00000000] 'one-shot sample
        pause 200
        I2CWRITE dp,cp,$00,chip1,[%11111111] 'one-shot sample 
        pause 200
         goto start   
    end
    Last edited by ScaleRobotics; - 27th November 2010 at 16:09. Reason: added code tags

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