Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

interrups and analog input problem.....

Status
Not open for further replies.

pe1riv

New Member
hello,

Still using the 18f2550 and the 18f program oshon software.

After being helped with interrupt problem I now have the following problem.....


Is it possible to use analog inputs and interrups together ?

I ask this because if I make it into analog, the ports that are used for interrups are also going to be analog inputs and than the interrups won't work....

If I put the "alldigital" than the interrups will work but than ofcoarse no analog inputs....

Is there an trick to make the a ports analog and the b ports digital (on b port are the interrups) ?
 
I'm really not following you..... If a pin is connected as an ADC input and a completely different pin is a switched input ( digital ) for interrupt.. this is allowed.

INT0 or INT1 or INT2 can be used on port B but you will not be able to use AN8, AN10 or AN12.. You can use any combination or part thereof....
 
tnx for reply,

if I make the ports analog they all going to be analog so all a and b ports including the interups pins (port b) because these pins of ic are used for several kinds of in/output.

And when they are in analog mode the interrups won't work.

I have no idea how to make the different pins into digital and analog mode the same time.

In oshonsoft I only can make everyting analog or digital.

So thats why I ask if there is a trick or some code to make the ports (or pins) in analog and digital mode the same time.

I need 4 analog inputs that I use from port a, an0,1,2,3 and I need (digital) 2 interrups (port b), swithes I put on port c (port c has no analog i/o), outputs (port c) is going via i2c to output extender ic, and i2c display
 
Last edited:
The datasheet on the PIC describes the use of the TRIState register which controls individual pin input output behaviour. Some PICs also use the ANSEL/ANSELH registers to control which pins are analog and capable of being used with the ADC. You can mix analog & digital pins on the same PORT. Not all PICS permit individual PORTB interrupt on change pin control. You need to check your PIC's datasheet.

On a 16F886 (I like this PIC) you can have individual control of the pins for analog, int on change (PORTB), digital I/O or weak pull ups(PORTB). This can be altered by the programming as you go along, so it's possible to use a pin as an output to drive an LCD screen data line and then repurpose it to sample the voltage drop across a thermistor on the same line. Once you know the drive capability of the PIN you can ensure that the thermistor won't overload the LCD data drive signal.
 
did read the pdf of the 2550 again and there was standing something about "adcon1" after a lot of trying I found out that if I put > adcon1= %1000 < that it will compile 4 analog inputs an0,1,2,3 and the rest digital so that the interups will work...

So now I can program the stuff and hope it will work....

Tnx for the replies.
 
Last edited:
Search the 18F2550 datasheet for ADCON it's explanation is very detailed.

PS personally I'd recommend typing all eight bits on a binary value e.g. ADCON1 = %00001000
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top