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.

interrupt problem

Status
Not open for further replies.

dorasu

New Member
Hello,

I am using MC9S12C32 microcontroller to control IO by using Port P(for sensor).I know this microcontroller can't set both falling and rising edges. That mean it can read when sensor detect the object, and then it can't read when sensor doesn't detect.

But my project need to read both detective or non-detective the object for sensor.

What should I change my program?

Thanks
 
How fast is the object moving? Set a timer to poll the sensor as fast as you possibly can. that way you can detect when there's an object and when there isn't. If you must use interrupts Port P and J will allow you to configure rising or falling edges.. Set it on rising edge.. then once the object is detected, swap the configuration to falling edge etc...
 
You can also use 2 pins as each edges' trigger. This is particularly good if you need two different routines, depending on edge.
Or, in hardware: capacitor link the sensor to a 1 shot set for minimum width. You'll get a narrow pulse on each transition. Somewhat sloppy, but simple... <<<)))
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top