??? 07/26/07 16:23 Read: times |
#142372 - Code wont work properly Responding to: ???'s previous message |
It is nice to see that you have posted your code.
All things are OK except that starting of Timer is not proper. Here is correction: MOV TMOD, #0Dh ;timer-0 in 16bit counter mode and gated with INT0 MOV TH0, highbyte(-10,001d) ; load value with -10001 d MOV TL0, lowbyte(-10,001d) JNB INT0,$ ;Wait for BUSY to go HIGH SETB TR0 ; start timer-0 JB INT0, $ MOV R0,TL0 MOV R1,THO As the measurement can commence any time, it may be in the middle of BUSY being HIGH so wait for rising edge of BUSY. Now this will give same reading everytime. If you find that with input zero, the reading is other than zero like 0FFFFh or 0001h then adjust the 10001 setting accordingly. |