In this project I made a stopwatch using PIC 18F4520. I also used an auxiliar circuit to make easy to pin stuffs in PIC18F. The project was coded on MPLABX IDE.
The PIC 18F4520 is based on Harvard architecture with reduced instruction set (RISC) type instructions. No PIC18F4520 contains 5 ports (A, B, C, D and E) and some pins of these ports may have other functions. Generally, when the pin is used for another function, it cannot be used with the I / O pin. Each port has 3 registers for its correct operation:
- TRIS register, which is responsible for directing (input or output) the ports, where a bit is at 0, or pin refers to an output pin and if the bit is at 1, or pin refers to an input pin ;
- PORT register, responsible for writing or reading the pin level associated with the port