to use periodic interrupt timer(PIT)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

to use periodic interrupt timer(PIT)

894 Views
navaneeth_ankam
Contributor II

hi,

i am working on MC9S12XDP512 microcontroller.and i have interfaced with proximity sensor. i have given 5v power supply and i was getting 5v when the obstacle was not present and 0v for when the obstacle was there. my objective is ,,,,,,when the obstacle is present for 2 seconds afterwards the LED should glow. or when there is no obstacle for 2 seconds afterwards also the LED should glow.

       so...i have used normal timer programing ...but i am not getting.so is better to use periodic interrupt timer(PIT).

Labels (1)
3 Replies

523 Views
RadekS
NXP Employee
NXP Employee

PIT is suited for output compare function only (generate period). I think that it will be difficult to use PIT for measuring of pulse with.

If I understood correctly, your problem with normal timer (ECT) is 2s interval = too long for TCNT timer. Correct?

In attachment you can find simple example code for measuring of pulse width by ECT module. This example code uses overflow interrupt for measuring longer pulses (longer than TCNT period). I suppose that you can simply modify this code for measuring both (0V and 5V) pulses.

You can also simply testing overflow variable for 2s limit in overflow interrupt routine.

Note: There is necessary take into account error of one TCNT period. If you want get better accuracy (of 2s limit), you should calculate with last value of TCx timer/resets TCx timer value….


523 Views
navaneeth_ankam
Contributor II

thank u...radek

i will try with this....and get back you

523 Views
navaneeth_ankam
Contributor II

hi,

i am working on MC9S12XDP512 microcontroller.and i have interfaced with proximity sensor. i have given 5v power supply and i was getting 5v when the obstacle was not present and 0v for when the obstacle was there. my objective is ,,,,,,when the obstacle is present for 2 seconds afterwards the LED should glow. or when there is no obstacle for 2 seconds afterwards also the LED should glow.

       so...i have used normal timer programing ...but i am not getting.so is better to use periodic interrupt timer(PIT).


0 Kudos