This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

URGENT!....how do i write a program for timing??


anyone out there..pls help me out!..

im having problems writing a program using uVision2 for a 8052 developement kit.

problem no.1: I have a Waveform of unknown freq from a swipe card which has TTL voltage of 0 and 5v. we need to design a program using C to count the time between the very 1st 2 high voltage
(1st 2 high V)

problem no.2: Next we hav to decode the waveform using a table. Basically its a Magnetic Swipecard we hav to decode, track 2 (eg 411557, 5bits per character)

half the program has been written so far but we can;t seem to output it to the LCD display...


HELP ME ANYONE PLEASE!!!...
Desperate.
ps: any qns, pls feel free to email me
arelius@visto.com

Parents
  • You should make use of the features of the Timer 2. You can feed the T2 input (Port 1) with a clock signal of a certain frequency... (maybe 100kHz) and use the T2EX input for the signal to be meassured. A 0->1 transition of it will cause an interrupt and the counter content will be captured in a certain 16-bit register. This way, you can meassure the period of the signal with the accuracy of your 100kHz clock. The Timer 2 has to be configured in capture mode. The operation of it is described pretty well in the datasheet of your processor.

    Take care
    Sven

Reply
  • You should make use of the features of the Timer 2. You can feed the T2 input (Port 1) with a clock signal of a certain frequency... (maybe 100kHz) and use the T2EX input for the signal to be meassured. A 0->1 transition of it will cause an interrupt and the counter content will be captured in a certain 16-bit register. This way, you can meassure the period of the signal with the accuracy of your 100kHz clock. The Timer 2 has to be configured in capture mode. The operation of it is described pretty well in the datasheet of your processor.

    Take care
    Sven

Children
  • Sven, This is the first time, ever, I have heard of clocking a timer with an external frequency. Please clarify your reasons for nut running T2 as a timer and using EX0 or EX1 to stop it.
    I am very curious as to why.

    Erik

  • Hi Erik,

    well, just looked it up again... you can sure use the internal clock too. I just remembered an old application of mine, where I used a variable external clock to meassure the length of something moving through a light barrier. The external clock was relative to the speed of the movement. So I was not sure, if the c51 would be able to use the internal clock for the capture mode... just too long ago :))

    Take care
    Sven