to use periodic interrupt timer(PIT)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

to use periodic interrupt timer(PIT)

918 次查看
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 回复数

547 次查看
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….


547 次查看
navaneeth_ankam
Contributor II

thank u...radek

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

547 次查看
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 项奖励