Embedded Systems Design PDF

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Summary

This document provides an introduction to embedded systems design. It covers digital input/output concepts, parallel I/O ports, and shows several code examples and diagrams for practicing PIC controllers. Designed for undergraduate-level students in electronics and computer engineering.

Full Transcript

Embedded Systems Design Digital Input and Output Dr. Bilal Arain Based on slides from Dr. Bassel Soudan Digital I/O Digital I/O stands for Digital Input and Output. Digital Inputs allow a microcontroller to detect logic states, and Digital Outputs allow a mi...

Embedded Systems Design Digital Input and Output Dr. Bilal Arain Based on slides from Dr. Bassel Soudan Digital I/O Digital I/O stands for Digital Input and Output. Digital Inputs allow a microcontroller to detect logic states, and Digital Outputs allow a microcontroller to output logic states. Digital Input: A digital input detects if a voltage on an interface pin is above/below a specific threshold. If the voltage is higher than the threshold, it will be detected as a logic 1. If the voltage is lower than the threshold, it will be detected as a logic 0. Digital Output: A digital output produces a voltage on an interface pin that represents the logic level. If you send a logic 1 to an output pin, a voltage (generally about 5 or 3.3 volts) will be produced on that pin If you send a logic 0 to an output pin, a voltage around 0 volts will be produced on that pin. Parallel I/O Ports Digital I/O ports are the means by which data from digital sensors can be brought in to the microcontroller and digital directives can be sent to actuators. A port is nothing but a group of I/O pins. These pins can be used individually (single bit I/O), or collectively (parallel I/O). Parallel I/O Ports Parallel I/O Ports Parallel I/O Ports - Example Parallel I/O Ports The PIC16F877 has five parallel ports: Ports and Digital Buffer Digital buffer performs no inversion or decision-making capabilities (like logic gates with two or more inputs) The buffer produces an output which exactly matches that of its input. The logical operation of a single input digital buffer is: “Output is true, only when Input is true” “Output is false, only when Input is false” Ports and Tri-state Buffer Digital buffer performs no inversion or decision- making capabilities (like logic gates with two or more inputs) The buffer produces an output that exactly matches that of its input. The logical operation of a single input digital buffer is: “Output is true, only when Input is true” “Output is false, only when Input is false” When activated into its third state it disables or turns “OFF” its output producing an open circuit condition that is neither at a logic “HIGH” or “LOW” Parallel I/O Ports Each port is controlled by two registers in the SFR TRISx controls the tri-state buffers that control the direction of the port The data direction is controlled by the corresponding bit in the TRISx register (‘1’ = input, ‘0’ = output) PORTx is a latch that is connected to the actual port pins (hold the data on the pins) Input/Output Ports Every port has its corresponding TRIS register: TRISA, TRISB, TRISC etc. which determines the performance of port bits, but not their contents. By clearing any bit of the TRIS register (bit=0), the corresponding port pin is configured as an output. By setting any bit of the TRIS register (bit=1), the corresponding port pin is configured as an input. Tri-State Buffer Tri-State Buffer Input/Output Ports of PIC16F877 Special Function Registers Some “high use” SFRs from bank0 are mirrored in the other banks (e.g., INDF, PCL, STATUS, FSR, PCLATH, INTCON) Port B Example Port B Example PIC I/O Ports Some pins of the I/O ports are multiplexed with an alternate function for the peripheral features on the device. In general, when a peripheral is enabled, that pin may not be used as a general purpose I/O pin. Port A Port A Port B Port B We will talk about this in detail once we get to the hardware interfacing portion of the course. Port C PORTC is an 8-bit wide, bi-directional port. The corresponding data direction register is TRISC. PORTC is multiplexed with several peripheral functions. PORTC pins have Schmitt Trigger input buffers. When the I2C module is enabled, pins RC4 and RC3 can be configured with normal I2C levels, or with SMBus levels by using the CKE bit (SSPSTAT). When enabling peripheral functions, care should be taken in defining TRIS bits for each PORTC pin. Some peripherals override the TRIS bit to make a pin an output, while other peripherals override the TRIS bit to make a pin an input. Port D PORTD and TRISD are not implemented on the PIC16F873 or PIC16F876. Port E PORTE and TRISE are not implemented on the PIC16F873 or PIC16F876. Which Port Should I Use? Sample Program Using Ports Another Example Count the number of button presses Which of these following two solution is correct? Connecting push button – Pull down configuration Connecting push button – Pull up configuration Bouncing Problem Combined Example Toggle LED each time the button is pressed. Practice Problem Design a system using the PIC to monitor 16 machines. Each machine produces a 1-bit signal, which is 1 if the machine is operating normally and 0 if it is not. The system should continuously read the status of the machines and display the count of machines operating normally on 7-segment displays. Practice Problem Write a program to receive a sequence of data values (8 bits each) from a digital camera and store them in consecutive memory locations. Before sending each new byte of data, the camera sends a 0-1-0 pulse on a wire connected to pin RA0 of the PIC. When the PIC receives the pulse, it should read the new value from Port B and save it in internal data memory. A maximum of 255 bytes are allowed. So, if the number of received bytes reaches 255, the PIC should set pin RA1 to 1 and stop accepting new values. Practice Problem - Hardware Interface

Use Quizgecko on...
Browser
Browser