DipSwitch


Closed Thread
Results 1 to 17 of 17

Thread: DipSwitch

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

    Default DipSwitch

    I have this code below to control the TSA5511 for a PLL for FM (87-108MHZ)

    DEFINE I2C_SCLOUT 1

    SYMBOL SDA=PORTA.0
    SYMBOL SCL=PORTA.1

    SYMBOL DIP1=PORTB.7
    SYMBOL DIP2=PORTB.6
    SYMBOL DIP3=PORTB.5
    SYMBOL DIP4=PORTB.4
    SYMBOL DIP5=PORTA.2
    SYMBOL DIP6=PORTA.3
    SYMBOL DIP7=PORTB.3
    SYMBOL DIP8=PORTB.2
    SYMBOL DIP9=PORTB.1
    SYMBOL DIP10=PORTB.0

    ADDR1 VAR BYTE
    TMP VAR WORD
    PLLBASE 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

    OUTPUT SCL
    OUTPUT SDA

    The PIC is 16f84a and xtal = 4MHZ
    Because i want to add dipswitch , may use the RA4 as input.
    If i use the 16f628a how to configure , to add 4 dipswitch more.
    Attached Images Attached Images  

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


    Did you find this post helpful? Yes | No

    Default

    any help ;

  3. #3
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    I have read your question now a couple of times and it is not clear (at least to me) what you are asking.

    Are you wanting to get rid of your XTAL to gain more input lines? If you do, with the use of RA4 you will have 3 more but have requested 4. Please clarify your request.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by paul borgmeier
    I have read your question now a couple of times and it is not clear (at least to me) what you are asking.

    Are you wanting to get rid of your XTAL to gain more input lines? If you do, with the use of RA4 you will have 3 more but have requested 4. Please clarify your request.
    I now use 10 dipswitch as input (look at image) and i want to add more dipswitch.
    Can i use the pin which are for the xtal (ra6-ra7) as input , if i use the pic16f628.
    also the ra4 and the mclr(ra5).
    will i have problem if change the XTAL with internal OSC;
    Sorry for my English.

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


    Did you find this post helpful? Yes | No

    Default

    you shouldn't have too much problem using the internal OSC as your application (for what i remind of) is not really timing critical. Go Go Go use the internal OSC and the MCLR pin as you wish, they're free!

    The only thing you'll have to do is to change the config fuse.. see the FAQ

    Sorry for my English
    You don't want to hear my Greek My english is actually really poor myself too but who cares as long as somebody understand it
    Last edited by mister_e; - 30th July 2006 at 15:34.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    you shouldn't have too much problem using the internal OSC as your application (for what i remind of) is not really timing critical. Go Go Go use the internal OSC and the MCLR pin as you wish, they're free!

    The only thing you'll have to do is to change the config fuse.. see the FAQ


    You don't want to hear my Greek
    Thank you for your answer.
    i need to use this;
    @ DEVICE pic16F628a, INTRC_OSC_NOCLKOUT
    @ DEVICE pic16F628a, MCLR_OFF

    May i use the RA4 as input;
    Do you speak greek(ellinika);
    Last edited by savnik; - 30th July 2006 at 15:40.

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


    Did you find this post helpful? Yes | No

    Default

    Yes you can use Ra4 as input.

    No i don't speek Greek... i may understand few words here and there but... yiissh.. hehe as the english expression said ... it's Greek to me Quebecer french says... it's Chinese to me... i heard also something like It's Gobledagook to me. I guess it depend where you're located.

    I speak French (native language) and a sort of English with few mistakes
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    Thank you again for help
    I live in Lesvos(Island)

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


    Did you find this post helpful? Yes | No

    Default

    i hope i found the right thing...
    παρακαλώ!
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    i hope i found the right thing...
    παρακαλώ!
    yes , is the right answer

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


    Did you find this post helpful? Yes | No

    Default

    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik
    I have this code below to control the TSA5511 for a PLL for FM (87-108MHZ)

    DEFINE I2C_SCLOUT 1

    SYMBOL SDA=PORTA.0
    SYMBOL SCL=PORTA.1

    SYMBOL DIP1=PORTB.7
    SYMBOL DIP2=PORTB.6
    SYMBOL DIP3=PORTB.5
    SYMBOL DIP4=PORTB.4
    SYMBOL DIP5=PORTA.2
    SYMBOL DIP6=PORTA.3
    SYMBOL DIP7=PORTB.3
    SYMBOL DIP8=PORTB.2
    SYMBOL DIP9=PORTB.1
    SYMBOL DIP10=PORTB.0

    ADDR1 VAR BYTE
    TMP VAR WORD
    PLLBASE 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

    OUTPUT SCL
    OUTPUT SDA

    The PIC is 16f84a and xtal = 4MHZ
    I want after set the frequency with the dip switch the PIC to go to sleep until i change the frequency again with the dip switch.
    I want the PIC to go to sleep after about five seconds.
    But i don't know how.

  13. #13
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Default

    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 !
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

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

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

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

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