i want use timer in msp430G2553..

i want to calculate time like for ultrasonic sensor.the time between transmitter( triggering) and receiver(Echo). how do i use it.please tell me

i am using ultrasonic sensor

i am using ultrasonic sensor HC-sr402 for object detection.so i will give 10usec pulse for triggering(input to sensor) if there is object then echo will receive on GPIO(output of sensor) . i want to calculate the time between triggering and Echo(High) received. thanking you...

Hi yogesh, A simple way I

Hi yogesh,

A simple way I suggest you could achieve this is through using a cross detect block and a pulse counter. Please find attached a simple diagram that does the same on an input square wave. Please replace the square wave with the input signal and you should be able to count the number of pulses and in turn derive the distance.

Hope this is helpful.


Sreeram Mohan

how to reset the counter

i have modify the pulse counter as per my application, i want to reset the counter and start from initial condition when the input pulse goes from high to low, i tried but do not understand please help me how to do it please find the attachment thanks yogesh


counting a pulse of 0.0625usec

hi sir, i can measure the pulse width if i count the pulse of 0.0625 usec. i tried to count but dosnt show the output .plz help me thanks. yogesh


Please attach your current

Please attach your current diagram.

rough idea for pulse width measurement

i want to measure the pulse width, i am working on MSP430G2553 which is 16 MHz. Fsc = 16MHz = 1/T ; T = 0.0625usec ;

determine the number of clock that occurred during the pulse;

count(time/clock)=ending count-starting count;

pulse width = T * count(time/clock);


Hi Yogesh, Could you provide

Hi Yogesh,

Could you provide more details of the sensor that you are talking about ?

If you just want to send out an IO pulse high and wait for IO on the other and clock it you should atleast start looking at : 1) Setup a GPIO to be high or any pattern according to the transmitter requirement. 2) Configure the GPIO read to be on an interrupt and this interrupt can be used on a compound and perform any operation needed.

I would recommend you send us more details and may be we can understand better on what is needed !


Sreeram Mohan

hii sir, as you said above

hii sir, as you said above I created a compound block on Pin P1.2 (Echo) and enable the interrupt on rising edge. but how can i use this interrupt for calculating the time and distance. thanks in advance..