to use periodic interrupt timer(PIT)

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

to use periodic interrupt timer(PIT)

1,220件の閲覧回数
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).

ラベル(1)
3 返答(返信)

849件の閲覧回数
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….


849件の閲覧回数
navaneeth_ankam
Contributor II

thank u...radek

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

849件の閲覧回数
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 件の賞賛
返信