CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Rising and falling Interrupt

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
rayhall



Joined: 05 Jun 2010
Posts: 2
Location: Cairns, Australia

View user's profile Send private message

Rising and falling Interrupt
PostPosted: Sat Jun 05, 2010 9:38 pm     Reply with quote

I am using the PIC18F2620.

I want the external interrupt to trigger on both rising and falling edges. The only options I can find are
Code:

ext_int_edge( L_TO_H );
ext_int_edge( H_TO_L );

I need something like, ext_int_edge( H_OR_L );

Ray.
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Sun Jun 06, 2010 9:38 am     Reply with quote

What you can do is change the edge at the next interrupt.

I've done that in the past and it's works fine.

Just do an IF to check to see which way the level is currently set and then set/clear it as appropriate.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
meereck



Joined: 09 Nov 2006
Posts: 173

View user's profile Send private message

PostPosted: Sun Jun 06, 2010 12:50 pm     Reply with quote

You can use PORTB interrupt (int_rb) for detecting level changes.
Most PICs support that interrupt.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jun 06, 2010 1:02 pm     Reply with quote

Right, but on the 18F2620 you can't enable the PortB pins on an individual
basis for Interrupt-on-change. He would have to change to the K-series
(18F26K20) to get that capability. The K-series only runs at 3.6v max,
so that could be a limitation.
rayhall



Joined: 05 Jun 2010
Posts: 2
Location: Cairns, Australia

View user's profile Send private message

PostPosted: Sun Jun 06, 2010 3:40 pm     Reply with quote

Thank you for the replies.

I have been using Atmel in the past, and I must say, I see the PIC interrupts as flawed for not having this. It just makes for more complicated code.

I hope as I use the PIC more, I do not find other flaws like this.

Ray.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

i had to solve that same problem on another part
PostPosted: Sun Jun 06, 2010 7:40 pm     Reply with quote

its not perfect but i did make it work in MY case.

IF you have a SPARE pin elsewhere on port B -
you can solve it the way i did:

* choose a portB or ANY other digital input pin and connect
your input signal to it.

* pick a portB pin with edge int - set LOW to HI trigger
and drive IT with the output of a 74HC86 EXOR gate -

* feed the SAME source signal into ONE input of the exor gate
and feed the OTHER input with the same signal thru
a 1K resistor shunted to ground
( at the pin input ) with a 2 -20 pf capacitor.

you may need to adjust the capacitor value based on your frequency
of state transitions but 5 pf is a safe value for even 100 khz rate

this produces very narrow pulses in the 100 nano second range or less
and the idle state is always zero - but i found i could reliably trigger the interrupt and then read the ACTUAL hi or LOW state on the second pin i was paralleled to - to do the actual reading of HI or LOW

yes it requires some hardware and an extra pin - but it will work - in my case with square waves in the 50 khz range - getting both transitions

hope it helps you
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group