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.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…