??? 05/16/07 18:24 Modified: 05/16/07 19:11 Read: times |
#139377 - 8051 frequency meter. Interrupt question |
Hi!!! This is my first message. I love this page.
Well, I'm building a frequency meter with a AT89s8252 (AT89c2051 in the future) and a 16x2 LCD display. My intention is to use a 24MHz crystal to be able to measure 2MHz max frequency value. I'm using timer0 as a external counter and timer1 to count 1sec. So, the frequency is the value of TH0 TL0 (hex value). With that config, if the frequency measured is above 65535 hertz, the counter will reset, and the value will be wrong. I was thinking to use timer0 interrupt and have a 3rd byte for the frequency so the max value can be FF FF FF (aprox 1.6MHz) So, maybe instead of using timer1 to count 1 sec, I can use timer1 to count half a sec, so, after counting the frequency, I multiply by 2 the 3 bytes of the counter (3rd byte - TH - TL) to have the frequency measured. I've never used interrupts, so I was wondering if my code is OK. Can you help me? this is my code, only the important things. I'm using timer1 for serial port so the delay is with nested loops. org 0 ljmp 1000h org 000Bh inc byte3 reti org 1000h ... serial port config.... ORL TMOD,#05H ; init the counter com: clr et1 mov th0,#0 ; reset the counter mov tl0,#0 mov byte3,#0 setb tr0 setb et0 lcall dealy_1sec clr tr0 lcall display_frec sjmp com what do you think?? thanks =) |
Topic | Author | Date |
8051 frequency meter. Interrupt question | 01/01/70 00:00 | |
Formatted Code | 01/01/70 00:00 | |
Thanks Jon | 01/01/70 00:00 | |
No Problem - What about EA | 01/01/70 00:00 | |
EA | 01/01/70 00:00 | |
corrected code | 01/01/70 00:00 | |
that is a pipe dream | 01/01/70 00:00 | |
External hardware | 01/01/70 00:00 | |
Why no more than 100K? | 01/01/70 00:00 | |
the obvious way to do this is to use one timer as | 01/01/70 00:00 | |
there is a 3rd byte | 01/01/70 00:00 | |
no good | 01/01/70 00:00 | |
assuming you can do the math... | 01/01/70 00:00 | |
HUH | 01/01/70 00:00 | |
And what? | 01/01/70 00:00 | |
... and ... | 01/01/70 00:00 | |
Eh? | 01/01/70 00:00 | |
the counter is not 'a counter' | 01/01/70 00:00 | |
you should be on the safe side... | 01/01/70 00:00 | |
who cares who 'wins' | 01/01/70 00:00 | |
Continuation... | 01/01/70 00:00 | |
now let\'s cheat | 01/01/70 00:00 | |
Get something working first | 01/01/70 00:00 | |
I diasagree | 01/01/70 00:00 | |
It's WORKING!!![]() | 01/01/70 00:00 |