PDA

View Full Version : DipSwitch



savnik
- 29th July 2006, 09:33
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.

savnik
- 30th July 2006, 14:00
any help ;

paul borgmeier
- 30th July 2006, 14:20
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.

savnik
- 30th July 2006, 14:32
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.

mister_e
- 30th July 2006, 15:26
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 ;)

savnik
- 30th July 2006, 15:34
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);

mister_e
- 30th July 2006, 15:39
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 ;)

savnik
- 30th July 2006, 15:48
Thank you again for help
I live in Lesvos(Island)

mister_e
- 30th July 2006, 15:52
i hope i found the right thing...
παρακαλώ!

savnik
- 30th July 2006, 16:14
i hope i found the right thing...
παρακαλώ!
yes , is the right answer

mister_e
- 30th July 2006, 16:19
Ouf!

Thanks http://www.ectaco.co.uk/English-Greek-Dictionary/

savnik
- 4th September 2006, 19:23
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.

BigWumpus
- 4th September 2006, 20:16
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 !

savnik
- 4th September 2006, 21:14
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


@ 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

mister_e
- 4th September 2006, 22:28
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

savnik
- 5th September 2006, 08:46
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.

sayzer
- 5th September 2006, 08:58
....(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!




----------------------------