Up Counter Using Timer0
This PIC Microcontroller project shows an Up Counter using Timer0. To simulate this circuit, initially activate Mixed Mode simulator from the Schematic Editor window. Simulation can be performed by selecting Run Transient analysis (Oscillograph) from Simulation menu.
The circuit contains a PIC Microcontroller, Binary to 7- Segment Decoder/Driver and
7-Segment LED Display.
In this circuit PortB is set as Output Port. Counter mode is selected by setting the TOCS bit in the Option Register. Timer0 counts according to the Prescaler bits (PS2, PS1, and PS0) set in the Option Register
The source code written in Assembly language can be viewed from the
code editor window
The program is as shown:
include "p16c5x.inc"
start code
movlw 0x00 ;moving literal constant 0x00 to W
tris PORTB ;setting PORTB in output mode
movlw 0x20 ;moving literal constant 0x20 to W
option ;selected the Counter mode
loop2 movf TMR0,0 ;moving the TMR0 value to W
movwf PORTB ;outting the contents of W through PORTB
goto loop2 ;repeating loop2
end ;directive 'end of program'
The source code in the
code editor window
has to be
compiled
after making any modifications
(editing).
Also the code can be
debugged
during
simulation.