A programmable counter can be made by a microcontroller. AT89S51 have two timers that can be operated as independent counter. To do this, we must set c/t bit at TMOD register. This sample will operate timer 0 as mode 2 counter. By loading 155des at TL0 and TH0, timer 0 act as 100des counter.
A simple frequency counter can be made by this counter.
This program also acts as frequency divider. The clock frequency will be divided by 100 and emitted to P3.2. Press INT0 for pause and INT0 again to resume.
Here is the listing program.
No comments:
Post a Comment