|
|||||
Chapter 3 problems |
- B3.3 - |
4-bit ones counter |
|||
|
1. Specifications
Design the 4-bit ones counter represented in Fig. 1 using a PIC18F4520. The same project is proposed in D1.3 as a combinational circuit based on logic gates.
|
Fig.1. Symbol and truth table. |
- Use the following pin connections:
D3 --> RC4; D2 --> RC3; D1 --> RB6; D0 --> RA1
Y2 --> RA2; Y1 --> RB5; Y0 --> RB0
Some questions to organise the project:
- List all the RAM variables involved in this design.
From a simiar tutorial in P9 or LAB9 where to copy and adapt to the project location folder:
- Draw an sketch of the hardware circuit and capture it in Proteus ones_counter_4bit.pdsprj
- Write the software source file ones_counter_4bit.c. Start an MPLABX - XC8 project targeted to the PIC18F4520 chip. Use our software organisation.
As we have decided, start compiling and testing one input or output at a time:
- Write the funcion init_system(). Start configuring only one input, compile and test. Describe using pictures and annotations how you are configuring registers.
- Write the funcion read_inputs(). Start reading only one input, compile and test. Describe using pictures and annotations how you are reading an input using bitwise C instructions.
- Write the funcion write_outputs(). Start writing only one output, compile and test. Describe using pictures and annotations how you are writing a RAM variable in the corresponding pin using bitwise C instructions.
- Translate the truth table to C code and complete truth_table().
- Check the full project and report.