Searching \ for '[PIC] Trouble with ANSEL and Interrupts' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ints.htm?key=interrupt
Search entire site for: 'Trouble with ANSEL and Interrupts'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Trouble with ANSEL and Interrupts'
2006\09\14@020847 by Dan Price

picon face
Hi, I am new to MCU programming and working with a 16F690 on a
PICKIT2.  I am working on a display consisting of about 60 LED's
driven by several 8-bit shift and store registers.  The basic idea is
to trigger various patterns that change at a momentary button press
and operate at different loop speeds based on the value of a
potentiometer.

All was going great until I started trying to setup an Interrupt
triggered by the momentary button.   First off I am coding in C
becuase I work much faster than in asm; however, I have been hard
pressed to find external interrupt code in C to use as examples.
Most of what I've found is either in assembly or all about the
internal timer based interuppts.  I have searched the web, I have a
couple of Predko books and looked through books in my local book store
without any luck so any resources that people can provide will be
greatly appreciated.  That being said and my noob status established
here is the problem:

In order to get the interrupt event to work I have to set the ANSEL
register.  I set this to 0 as I am only interested in triggering the
interrupt.  All ports other than RA2 for the button interrupt are
outputs and no analog stuff is necessary at this time.  With the ANSEL
register set to zero my interrupt works perfectly and cycles through
each display pattern as intended, but suddenly there is all kinds of
noise on the LED's.  Each LED now flickers a small amount at all times
during the various pattern routines.  Additionally, the patterns
themselves are slightly corrupted with some bits shifting incorrectly.
This corruption is consistent and not random.  I have tried messing
around with a variety of different registers with no joy.  If I
comment out the ANSEL entry this problem goes away.  Can someone
please provide some suggestions, a bit more explanation on the ANSEL
register and most importantly some good C based resources for
externally driven interrupts? Thanks, Dan

2006\09\14@022608 by John Temples

flavicon
face
On Thu, 14 Sep 2006, Dan Price wrote:

> I have been hard
> pressed to find external interrupt code in C to use as examples.

Most compilers use different syntax for interrupts.  Which compiler
are you using?  What does your ISR look like?

--
John W. Temples, III

2006\09\14@082818 by genome

picon face
put eather a software delay or a hardware delay by using a timing capacitor
in parallel and a pullup resistor when querying for input on the interrupt 1
millisecond is good enough delay.. If you go with the hardware solution you
will need a an input pin assigned to the button that is schmitdt triggered
as the rising time for the button pulse is greatly reduced..
the button may be springing... and producing unwanred pulses...

"Dan Price" <spam_OUTdanielspriceTakeThisOuTspamgmail.com> wrote in message
news:.....4800c2c60609132308t6ff5ff2ua1715e893804272dKILLspamspam@spam@mail.gmail.com...> {Quote hidden}

> --

2006\09\14@083301 by jtroxas

picon face
put eather a software delay or a hardware delay by using a timing capacitor
in parallel and a pullup resistor when querying for input on the interrupt 1
millisecond is good enough delay.. If you go with the hardware solution you
will need a an input pin assigned to the button that is schmitdt triggered
as the rising time for the button pulse is greatly reduced..
the button may be springing... and producing unwanred pulses...

{Original Message removed}

2006\09\14@175328 by Dan Price

picon face
>Most compilers use different syntax for interrupts.  Which compiler
>are you using?  What does your ISR look like?

>--
>John W. Temples, III

I'm using MPLAB 7.3  and PICC LITE 9.5.  My basic ISR is as follows:

static void interrupt
isr(void)                        
{
INTF = 0;
RABIF = 0;
       if (choice == 8)
       choice = 0;
       else
       choice++;
}

I have also tried including a delay via a for loop to function as a
debounce but this has had no effect one way or the other.

2006\09\14@175900 by Dan Price

picon face
>jtroxas wrote:
>put eather a software delay or a hardware delay by using a timing capacitor
>in parallel and a pullup resistor when querying for input on the interrupt 1
>millisecond is good enough delay.. If you go with the hardware solution you
>will need a an input pin assigned to the button that is schmitdt triggered
>as the rising time for the button pulse is greatly reduced..
>the button may be springing... and producing unwanred pulses...

Thanks for the response.  The first thing I thought of was button
"bounce" so I tried a software delay and tried activating the built in
pull-ups in the mcu to no avail.  I was going to go with a hardware
solution but the thing is that if I physically remove the button from
my breadboard the problem still persists.  This suggests to me that
the button itself is not the problem.  Is there some other way I could
be getting bounce-like intereference or  some kind of cross-talk
simply by turning ANSEL off?

2006\09\14@180651 by Jan-Erik Soderholm

face picon face
> Is there some other way I could
> be getting ...  some kind of cross-talk
> simply by turning ANSEL off?

Un-connected digital I/O pins set as inputs ?

Jan-Erik.



2006\09\14@210227 by genome

picon face
maybe try to show the code you have written.. maybe its just software... as
wirh interrupts you must clear some flags before exiting the interupt
routine or the interrupt will just go loop forever..

"Dan Price" <danielspricespamKILLspamgmail.com> wrote in message
news:.....4800c2c60609141458g46821400yfb249b309e1b5b82KILLspamspam.....mail.gmail.com...> {Quote hidden}

> --

More... (looser matching)
- Last day of these posts
- In 2006 , 2007 only
- Today
- New search...