DipSwitch


Results 1 to 17 of 17

Thread: DipSwitch

Threaded View

  1. #8
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BigWumpus
    Using such a lot of switches....

    you should read the articles who use a analog-port to read 4-7 switches !!!

    Sleeping:

    You have to use a timer to awake (!), because, there is no interrupt covering all your switches.
    So you have to save the switches in your RAM, set a timer to wait a time (prescaler, postscaler, ...) to wake up, enable the neccessary interrupts and go sleep. The interrupt will wake up the PIC at the next position (imho) and you have to check, if any switch has been moved.
    Loop !
    I have change the code
    Code:
    @ DEVICE pic16F628a, INTRC_OSC_NOCLKOUT     ' System Clock Options 
    @ DEVICE pic16F628a, MCLR_OFF	            ' Master Clear Options (Internal)
    
    CMCON = 7               ' PortA = digital I/O
    
    DEFINE I2C_SCLOUT 1
    
    SYMBOL SDA=PORTA.0      ' SDA  var  PORTA.0
    SYMBOL SCL=PORTA.1      ' SCL  var  PORTA.1
    
    SYMBOL DIP1=PORTB.7
    SYMBOL DIP2=PORTB.6
    SYMBOL DIP3=PORTB.5      
    SYMBOL DIP4=PORTB.4
    SYMBOL DIP5=PORTA.6
    SYMBOL DIP6=PORTA.7
    SYMBOL DIP7=PORTA.2 
    SYMBOL DIP8=PORTA.3
    SYMBOL DIP9=PORTA.4
    SYMBOL DIP10=PORTA.5 
    SYMBOL DIP11=PORTB.3
    SYMBOL DIP12=PORTB.2 
    SYMBOL DIP13=PORTB.1
    SYMBOL DIP14=PORTB.0
    
    ADDR1 	VAR BYTE
    TMP   	VAR WORD
    PLL   	VAR WORD
    LO    	VAR PLL.LOWBYTE
    HI    	VAR PLL.HIGHBYTE
    
    INPUT DIP1
    INPUT DIP2
    INPUT DIP3
    INPUT DIP4
    INPUT DIP5
    INPUT DIP6
    INPUT DIP7
    INPUT DIP8
    INPUT DIP9
    INPUT DIP10
    INPUT DIP11
    INPUT DIP12
    INPUT DIP13
    INPUT DIP14
    
    OUTPUT SCL
    OUTPUT SDA
    
    ADDR1=$C2
    Never use interrupt and i don't how
    Last edited by savnik; - 4th September 2006 at 21:29.

Similar Threads

  1. PIN state VS Variable read
    By cburtis in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th December 2007, 11:54
  2. Dipswitch matrix
    By DynamoBen in forum Off Topic
    Replies: 10
    Last Post: - 8th October 2007, 17:11

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