DipSwitch


Closed Thread
Results 1 to 17 of 17

Thread: DipSwitch

Hybrid View

  1. #1
    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.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    so you should, once again, open the datasheet in the SLEEP section first.

    Have a look at section 14.8 Power-down mode and section 14.8.1 Wake-up from sleep. There, you will discover what can wake-up your PIC
    External RESET
    Watchdog timer
    Interrupt from RB0/INT pin, interrupt on some PORTB pins or peripheral interrupts (comparator, USART... )

    without some change to your hardware... i doubt you'll be able to wake your PIC ONLY if you change some dip switch.

    to turn your PIC in sleep mode only for 5 secondes, you may have a look in the PBP book at SLEEP section.

    SLEEP 5
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    so you should, once again, open the datasheet in the SLEEP section first.

    Have a look at section 14.8 Power-down mode and section 14.8.1 Wake-up from sleep. There, you will discover what can wake-up your PIC
    External RESET
    Watchdog timer
    Interrupt from RB0/INT pin, interrupt on some PORTB pins or peripheral interrupts (comparator, USART... )

    without some change to your hardware... i doubt you'll be able to wake your PIC ONLY if you change some dip switch.

    to turn your PIC in sleep mode only for 5 secondes, you may have a look in the PBP book at SLEEP section.

    SLEEP 5
    I have read datasheet many times.(I don't understand datasheet very well because i don't know english very well)
    I want to wake PIC ONLY if i change one or some dip switch and after 5 seconds to go to sleep again , until if i change one or some dip switch again.
    But i don't know how to write the code.

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik
    ....(I don't understand datasheet very well because i don't know english very well).....

    Hi savnik,

    Since you know the difference of using "well" instead of "good", your English seemed very well to me!




    ----------------------------
    Last edited by sayzer; - 5th September 2006 at 18:56.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

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