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

Interrupts on two lines?-- Easy Question

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



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

Interrupts on two lines?-- Easy Question
PostPosted: Fri Jun 24, 2005 7:15 am     Reply with quote

Hi

I have two signals going from 0 to Vss and back to 0.
Can someone please tell me how I can determine when the signals go L-H and H-L? The two signals have no sequence and either can go H first.
Can I use two external interrupts?

Thank you for your help.
arrow
valemike
Guest







PostPosted: Fri Jun 24, 2005 8:50 am     Reply with quote

Okay, for one of the interrupts, you may use Rb0:

Code:

/* Set up RB0 as an interrupt */
    ext_int_edge(H_TO_L);      // init interrupt triggering for limit switch
    enable_interrupts(INT_EXT);


As for the other interrupt, when i have time (or someone else can answer it), i'll look at the documentation for how to set up interrupt on change on the other portB pins. Off hand, i'm not aware if i can set H_TO_L or L_TO_H on the other interrupts.

Your application sounds very much like an encoder. Depending on the direction the shaft is turning, one signal will lead the other and vice versa. If this is the case, then you don't need two interrupts; you just need one. If rb0 causes an interrupt, then in your isr, you would look at the state of the other pin.

If your two interrupts are purely independent of each other, then yes, you will still need an answer to your question on how to configure the edge interrupt of the other pin.


-Mike
Guest








PostPosted: Fri Jun 24, 2005 9:08 am     Reply with quote

Hi valemike

Thank you for your reply.

Yes I have two trully independent interrupts.
They are comming from a 2 axis accerlometer.

I can check if its H-L or L-H programmatically.

Regards
arrow
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Fri Jun 24, 2005 9:34 am     Reply with quote

You can also do this with the interrupt on change feature of B4-B7, #int_RB.

About a year ago I posted an interrupt driven keypad routine. It's in the code library. You'll have to go to the 2nd page of postings; I believe it's called "complete listing - interrupt driven keypad routine."

Examine the code and see if you can figure out how it works. It can be quite easily modified to pick up on your two separate lines going L-H and H-L.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Jun 24, 2005 10:44 am     Reply with quote

FYI

Vss is usually 0V
Vdd is usually 5V
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Fri Jun 24, 2005 10:59 am     Reply with quote

You could use a hardware approach. Take 2 S-R latches such as CD4043 or CDCD4044 and connect your accelerometer signals to the S inputs. Your accelerometer spike will latch in the S-R latches and they you just poll the Qs and reset the buffers with Rs. This approach frees up your interrupts. On the other hand it introduces a delay, a variable one.

Nick
sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

PostPosted: Fri Jun 24, 2005 1:19 pm     Reply with quote

kender wrote:
You could use a hardware approach. Take 2 S-R latches such as CD4043 or CDCD4044 and connect your accelerometer signals to the S inputs. Your accelerometer spike will latch in the S-R latches and they you just poll the Qs and reset the buffers with Rs. This approach frees up your interrupts. On the other hand it introduces a delay, a variable one.

Nick


I kind of like the hardware approach for this, but this approach seems dependent upon whether the accelerometer spike can latch the flipflops.

Without going through truth tables to figure out what logic you need to use on channel A and B to generate a pulse on every transition of A and B, you could route both signals to positive and negative edge triggered one shots (for a total of four one shots). You could either OR all of these one shots together and send the result to your external interrupt, an on interrupt poll both A and B, or you can send the output of all four one shots to the high bits of portB, and which line generates the interrupt tells you which transition happened.

This is CLEARLY the brute force approach.
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Fri Jun 24, 2005 7:46 pm     Reply with quote

Quote:
...but this approach seems dependent upon whether the accelerometer spike can latch the flipflops.


You're right - comparators would be highly advisable. Here as well as in the 2 interrupt lines approach.
valemike
Guest







PostPosted: Fri Jun 24, 2005 9:25 pm     Reply with quote

Anonymous wrote:
Yes I have two trully independent interrupts.
They are comming from a 2 axis accerlometer.


There is a rather straightforward circuit that Freescale uses to implement its MC13192 development kit. It has a 2-axis accelerometer and a 1-axis accelerometer. It runs on batteries too.

The code is in C, so you can probably find out how to it.
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Sat Jun 25, 2005 1:35 am     Reply with quote

Hi Valemike and All

Thank you all for responding. This gives me quite a few lines of approach!

Valemike can you please post the URL where I can find the C code for the MC13192 Freescale accelerometers?

All the best
arrow
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