Embedded System Design - Chapter 7: Peripherals for embedded systems (Part 2)

7.3. Analog Input
• Allows an external voltage to be converted to digital
form, stored and processed
• This type of input occurs in data loggers, control
systems, digital audio and signal processors…
• The PIC microcontrollers is designed specifically for high‐
speed analog signal processing 
pdf 23 trang thamphan 26/12/2022 3560
Bạn đang xem 20 trang mẫu của tài liệu "Embedded System Design - Chapter 7: Peripherals for embedded systems (Part 2)", để tải tài liệu gốc về máy hãy click vào nút Download ở trên.

File đính kèm:

  • pdfembedded_system_design_chapter_7_peripherals_for_embedded_sy.pdf

Nội dung text: Embedded System Design - Chapter 7: Peripherals for embedded systems (Part 2)

  1. 8/9/2016 ĐẠI HỌC QUỐC GIA TP.HỒ CHÍ MINH TRƯỜNG ĐẠI HỌC BÁCH KHOA KHOA ĐIỆN-ĐIỆN TỬ BỘ MÔN KỸ THUẬT ĐIỆN TỬ Embedded System Design Chapter 7: Peripherals for embedded systems 7.1 Digital parallel input / output 7.2 LCD interfacing 7.3 Analog input /output 7.4 Serial communication Bộ Môn Kỹ Thuật ĐiệnTử - ĐHBK 1 7.3. Analog Input • Allows an external voltage to be converted to digital form, stored and processed • This type of input occurs in data loggers, control systems, digital audio and signal processors • The PIC microcontrollers is designed specifically for high‐ speed analog signal processing Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK Chapter 7 - p2 2 1
  2. 8/9/2016 Analog Setup U1 13 33 • The PIC 16F877 has eight analog OSC1/CLKIN RB0/INT 14 34 OSC2/CLKOUT RB1 1 35 inputs: RA0, RA1, RA2, RA3, MCLR/Vpp/THV RB2 36 RB3/PGM 2 37 RA0/AN0 RB4 RA5, RE0, RE1, RE2 being 3 38 RA1/AN1 RB5 4 39 RA2/AN2/VREF- RB6/PGC renamed AN0 to AN7. 5 40 RA3/AN3/VREF+ RB7/PGD 6 RA4/T0CKI 7 15 RA5/AN4/SS RC0/T1OSO/T1CKI 16 RC1/T1OSI/CCP2 8 17 RE0/AN5/RD RC2/CCP1 9 18 RE1/AN6/WR RC3/SCK/SCL 10 23 RE2/AN7/CS RC4/SDI/SDA 24 RC5/SDO 25 RC6/TX/CK 26 RC7/RX/DT 19 RD0/PSP0 20 RD1/PSP1 21 RD2/PSP2 22 RD3/PSP3 27 RD4/PSP4 28 RD5/PSP5 29 RD6/PSP6 30 RD7/PSP7 Chapter 7 - p2 Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK PIC16F877 5 CCS C Analog Input Functions Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK Chapter 7 - p2 6 3
  3. 8/9/2016 Chapter 7 - p2 9 Example U1 13 33 OSC1/CLKIN RB0/INT RV1 14 34 OSC2/CLKOUT RB1 1 35 MCLR/Vpp/THV RB2 36 RB3/PGM 2 37 RA0/AN0 RB4 3 38 RA1/AN1 RB5 4 39 RA2/AN2/VREF- RB6/PGC 5 40 RA3/AN3/VREF+ RB7/PGD 1k 6 RA4/T0CKI 7 15 RA5/AN4/SS RC0/T1OSO/T1CKI 16 RC1/T1OSI/CCP2 8 17 RE0/AN5/RD RC2/CCP1 9 18 RE1/AN6/WR RC3/SCK/SCL 10 23 RE2/AN7/CS RC4/SDI/SDA 24 RC5/SDO 25 LCD1 RC6/TX/CK 26 RC7/RX/DT VDD 19 RD0/PSP0 RXD 20 RD1/PSP1 21 RD2/PSP2 VSS 22 RD3/PSP3 27 MILFORD-2X16-BKP RD4/PSP4 28 RD5/PSP5 29 RD6/PSP6 30 RD7/PSP7 PIC16F877 Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK Chapter 7 - p2 10 5
  4. 8/9/2016 Voltage measurement Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK Chapter 7 - p2 13 7.3. Analog Output Basic digital to analogue converter a) general DAC hardware b) output voltage Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK Chapter 7 - p2 14 7
  5. 8/9/2016 Ex: DAC0808 & Serial DAC Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK Chapter 7 - p2 17 Waveform Generator Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK Chapter 7 - p2 18 9
  6. 8/9/2016 Waveform Generator Source Code (3/3) Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK Chapter 7 - p2 21 Class Assignment • Design a system to read temperature data from the sensor LM35, and show the result on LCD LCD1 LM016L VSS VDD VEE RS RW E D0 D1 D2 D3 D4 D5 D6 D7 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK Chapter 7 - p2 22 11
  7. 8/9/2016 Serial Communication 1.PIC16 USART Serial Link 2.PIC16 SPI Serial Bus 3.I2C Serial Bus Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK Chapter 7 - p2 25 USART • The universal synchronous/asynchronous receive transmit (USART) device is typically used in asynchronous mode to implement off‐board, one‐to‐one connections. • The term asynchronous means no separate clock signal is needed to time the data reception, so only a data send, data receive, and ground wires are needed. • It is quick and simple to implement if a limited data bandwidth is acceptable. USART Operation Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK Chapter 7 - p2 26 13
  8. 8/9/2016 CCS RS232 Serial Port Functions Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK Chapter 7 - p2 29 RS232 Periperal Simulation Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK Chapter 7 - p2 30 15
  9. 8/9/2016 SPI Bus • The serial peripheral interface (SPI) bus provides high‐speed synchronous data exchange over relatively short distances (typically within a set of connected boards), using a master/slave system with hardware slave selection • One processor must act as a master, generating the clock. Others act as slaves, using the master clock for timing the data send and receive. • The slaves can be other microcontrollers or peripherals with an SPI interface. • The SPI signals are: – Serial Clock (SCK) – Serial Data In (SDI) – Serial Data Out (SDO) – Slave Select (!SS) Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK Chapter 7 - p2 33 SPI Bus SPI Connection SPI Signals Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK Chapter 7 - p2 34 17
  10. 8/9/2016 • SPI Test System Schematic Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK Chapter 7 - p2 37 Master and slaves source code Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK Chapter 7 - p2 38 19
  11. 8/9/2016 I2C Bus • The I2C slave chips are attached to a two‐wire bus, which is pulled up to logic 1 when idle. Passive slave devices have their register or location addresses determined by a combination of external input address code pins and fixed internal decoding. • As for SPI, the clock is derived from the instruction clock, up to 5MHz at the maximum clock rate of 20MHz. Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK Chapter 7 - p2 41 I2C Bus • To send a data byte, the master first sends a control code to set up the transfer, then the 8‐bit or 10‐bit address code, and finally the data. Each byte has a start and acknowledge bit, and each byte must be acknowledged before the next is sent, to improve reliability. • The sequence to read a single byte requires a total of 5 bytes to complete the process, 3 to set the address, and 2 to return the data Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK Chapter 7 - p2 42 21
  12. 8/9/2016 I2C Test System Bộ môn Kỹ Thuật ĐiệnTử - ĐHBK Chapter 7 - p2 45 23