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


Lecture 3

L9.3: basic I/O. Poll/read input values



[19/5] read_inputs()

Our goal: How to poll/capture/read input port pins? How to convert electrical signals (digital voltages) into RAM variables?

Read operation

Fig. 1.  Example on how to read inputs.

Mask, clean, shift and organise bits in convenient RAM variables. Bitwise logic operations (AND, OR, XOR, NOT, SHIFT). This is an example on how to read (or poll/acquire/capture) a signal connected to a μC pin and convert it into a convenient RAM variable. The concept of sampling an input at a given CLK active edge is a more complex concept to be explained in P10 on interrupts.

Microoperations for pooling a digital input

Fig. 2.  Sequence of bitwise operations. (pdf)

Study how read is organised in Adder_BCD_1digit.

3.4.3. Development & testing

Our target μC device: chip PIC18F4520 from Microchip. Hardware schematic capture: pdsprj file.

The simulation and testing tool to install in your computer using our cloud license: Virtual laboratory Proteus VSM Software development in C language

The IDE (integrated software develpment  environment) to install in your computer: MPLABX  with its C compiler XC8. Project compilation and chip configuration files: hex, cof

Compiler options: C90, COFF output file generation. Proteus simulation and testing. Step by step debugging, watch variables window

Run/stop, watch window, RAM variables, ROM (program memory), MCU registers and flags, step by step mode, break points, etc.

Measurements: main loop execution time. How fast is our circuit solving a truth table? How long does it take to execute an instruction in C or in assembly? Execution time of a section of code. Disassembly mode. µC OSC frequency.