L9.2: Basic I/O. Planning projects: general organisation of hardware and software. [P9] Hardware circuit, init_system() |
[26/11] |
3.4.2. Planning
3.4.2.1. Hardware schematic
3.4.2.1.1. Connecting switches and buttons
3.4.2.1.2. Oscillator (OSC) and reset (MCLR_L) circuits
Fig. 1. Example of typical external quartz crystal Oscillator. |
Fig. 2. Example of typical external MCLR_L circuit (CD_L): Power-ON reset (RC) network and active-low push-button for initialising the microcontroller.
|
3.4.2.1.3. Interfacing LED
3.4.2.1.4. Tri-state logic gates and wire bi-directionality. Bus concept.
The idea of tri-state gates and bidirectional wires and buses.
3.4.2.2. Software program
Fig. 3. Software organisation flowchart. |
3.4.2.2.1. RAM variables
In this charter, truth tables and all the software will be solved using RAM variables. For instance, if the input consist of D(3..0), the computer wil store a RAM variable type char named var_D. The four most significant bits of this memory position will be zeroed.
3.4.2.2.2. init_system(): I/O port pin configuration register (TRIS).
Our goal: How to configure a port pin as input or as output. TRIS data direction register.
Fig. 4. Example of pin direction configuration. |
|
Let discuss all there ideas designing an example circuit.
3.4.4.2. Adder_BCD_1digit
Exercise: Read the datasheet of the PORTC and draw the electronic circuit associated to a bidirectional pin.