UPC EETAC Bachelor's Degree in Telecommunications Systems and in Network Engineering EEL

Chapter 3 problems

      - B3.4 -

Circuit_VT (μC - C)

Products

B3.3

B3.5


1. Specifications

Design the combinational Circuit_VT in Fig. 1 using a microcontroller PIC18F4520. 

This circuit was already presented as a combinational hardware design in D1.4.

Symbol

Fig. 1. Symbol and truth table of the circuit to be designed. Be aware that in this symbol, inputs S(1..0) are represented in multi-wire vector form and A and B are single wires.

 truth table

Draw an example of timing diagram to be used later as stimulus in the Proteus simulation of the circuit. 

 

A) Planning hardware

Copy and adapt a circuit from any of the previous projects (LAB9) and name it Circuit_VT.pdsprj. Assign pins to inputs and outputs accordingly to one of the following options (your instructior will tell you which):

Pin assignment option #1:

S(1..0) --> RB(6..5)

A --> RA1 ; B --> RD3 ;

T --> RA2

V --> RC1

Pin assignment option #2:

S(1..0) --> RC(4..3)

A --> RB7 ; B --> RA3 ;

T --> RB6

V --> RD5

Pin assignment option #3:

S(1..0) --> RA(3..2)

A --> RD5 ; B --> RC2 ;

T --> RD6

V --> RB4

Project location:

C:\CSD\P9\Circuit_VT\(files)

B) Planning software

Organise the main program in our CSD way.

Propose a hardware-software diagram naming all the electrical signals, RAM variables and the software functions.  

Explain how to configure the µC in init_system(). List all RAM variables required and their type.

Organise using a flowchart the interface function read_inputs().

Organise using a flowchart the interface function write_outputs().

Infer the truth_table() software function using a behavioural interpretation and the corresponding flowchart.

 

Developing & testing (debugging)

Write the Circuit_VT.c source code translating the function flowcharts. Start capturing only one input as in (LAB9) and visualising it in the watch window. And only then go step by step developing & testing more inputs. 

Start a software IDE project for the target microcontroller PIC18F4520 and generate the configuration files ".cof" and ".hex" after compilation. Discuss the project summary: % of ROM used for the code, number of RAM bytes used, etc.

Add a few lines of code every time, compile and run the test intereactively to check results watching variables.

Note: Step-by-step tactical approach for developing and testing the project: Read one input at a time and run to check that the voltage value is correctly captured as a valid digital value in RAM memory. Write one output at a time and run to check that your code is correct to light the LED connected at the output pin.

Measure how long does it take to run the main loop code when using a 4 MHz and a 16 MHz crystall oscillators.