Hello Readers:
I have started this blog to show you Embedded C programming for 8051 family microcontroller using KEIL compiler. The KISS philosophy is used to write this tutorial. What is KISS? Keep It Simple, Stupid!
This program is used to count the visitors and total count range is 8 bits as Counter 1 is in Mode 2 auto reload. You can feed 1 Hz external clock into pin T1 (P3.5).
Code explanation:
Line 11: make T1 an input.
Line 12: set TimerMODe register for Counter 1 in mode 2.
Line 13: Initialize register to zero.
Line 17: Start the timer1.
Line 18: Place value on LED port pins.
Line 19: do the above steps till Timer Flag is not overflowed.
Line 20 & 21: Reset Timer and Timer Flag for next iteration.
After typing the code, press F7 or click Project->Build Target for building the source code. If there are no typical errors file will build successively and shows zero errors and zero warnings. You cannot simulate this as external clock pulse is not supplied in this program.
If you generate HEX file of this program, burn it into your target chip’s memory using suitable uploader and connecting 1 Hz external clock to Port 2 you can watch LEDs incrementing in binary form. To stop running the program press red ‘x’ mark icon or click Debug->Stop.
...till next post bye-bye & take care.
No comments:
Post a Comment