ECE 598 Advanced Operating Systems Lecture 6

Similar documents
ECE 598 Advanced Operating Systems Lecture 6

ECE 598 Advanced Operating Systems Lecture 6

ECE 598 Advanced Operating Systems Lecture 5

ECE 598 Advanced Operating Systems Lecture 7

ECE 598 Advanced Operating Systems Lecture 4

ECE 598 Advanced Operating Systems Lecture 8

ECE 598 Advanced Operating Systems Lecture 8

Sender Receiver Sender

RS 232 Interface. RS 232 is the Serial interface on the PC. Three major wires for the Serial interface: Transmit Pin 2 Receive Pin 3

CprE 288 Introduction to Embedded Systems (UART Interface Overview)

=0 Read/Write IER Interrupt Enable Register =1 Read/Write - Divisor Latch High Byte + 2

ECE 598 Advanced Operating Systems Lecture 11

Universal Asynchronous Receiver Transmitter Communication

Device: MOD This document Version: 1.0. Matches module version: v3 [29 June 2016] Date: 23 October 2017

UART. Introduction. Agenda

Serial Communication Prof. James L. Frankel Harvard University. Version of 2:30 PM 6-Oct-2015 Copyright 2015 James L. Frankel. All rights reserved.

Hardware Manual. PCMCIA 1 Port RS EDITION APRIL 1999

ECE251: Thursday November 8

Serial Interfaces Part 1. ECE 153B Sensor & Peripheral Interface Design Winter 2016

USB to RS-232/RS422/485. US-101-I USB To Serial Operation Manual

Pmod ESP32 Reference Manual

Hardware Manual PCMCIA DUAL RS EDITION MAY 1999

ECE 471 Embedded Systems Lecture 12

FEC-240G. Rev. Date

ECE 598 Advanced Operating Systems Lecture 18

Preliminary. PACKAGE - 28-pin MLP (5mm X 5mm) Example Circuit Diagram CP V. 48MHz Oscillator. USB Function Controller 512B EEPROM

A GUIDE TO RS-232 COMMUNICATION WITH FX PLCS

Configurable UART ver 2.10

CS/ECE 5780/6780: Embedded System Design

ECE 471 Embedded Systems Lecture 12

Real-Time Embedded Systems. CpE-450 Spring 06

BeagleBone Black USB Expansion RS232 Module Cape Coolgear, Inc. Version 1.1 September 2017 Model Number:

WiFi to RS-232 adapter user manual

Chapter 11: Input/Output Organisation. Lesson 05: Asynchronous RS232C Serial Port data transfer

SUNIX DEL2S00PL meets the PCI Express Base Specification Revision 2.0. It is compatible with PCI

Concepts of Serial Communication

LCD03 - I2C/Serial LCD Technical Documentation

USB-2COM-BB USER S MANUAL

3.1 I-7560 Pin Assignment and Specifications: Introduction

ECE 471 Embedded Systems Lecture 30

EE 354 November 13, 2017 ARM UART Notes

Hierarchy of I/O Control Devices

ECE/CS 5780/6780: Embedded System Design

Configurable UART with FIFO ver 2.20

Homework. Reading. Continue mp1. Labs. Tokheim, Section Questions? Continue labs with your assigned section

Section 1 Introduction

TKT-3500 Microcontroller systems

4.3 Digital Communication

ECE 471 Embedded Systems Lecture 6

ECE 598 Advanced Operating Systems Lecture 12

EX & EX-45362IS 2S RS232/422/485 3-in-1 Serial PCIe Card

ECE 471 Embedded Systems Lecture 4

BOARD LEVEL PRODUCTS GPIB<->RS-422/RS-485 INTERFACE BOARD

LCD03 - I2C/Serial LCD Technical Documentation

EMERALD-MM-8P. 8-Channel Software Programmable Protocol. Serial Port PC/104 TM Module. User Manual V1.20

Lecture 13 Serial Interfaces

Serial communication

ATmega128. Serial Communication (RS-232C)

//***************************************************************************** -1-

edbox-100 SmartStack Box for PSTN

Modbus Remote Communication Protocol for REM 54_. Technical Description

Operating Instructions. Sartorius. Description of the Interface for EA, EB, GD, GE and TE Balances/Scales

I/O Devices. Nima Honarmand (Based on slides by Prof. Andrea Arpaci-Dusseau)

CHAPTER 5 REGISTER DESCRIPTIONS

SIO-DLL. Serial I/O DLL. User Manual

Keyboards. The PS/2 Protocol

ECE 598 Advanced Operating Systems Lecture 10

Dual Serial Shield User Manual

Introduction Page 1. Power Supply Requirements & Hardware Options Page 2. External Connectors (Functions & Pinouts) Page 2

ECE 471 Embedded Systems Lecture 20

ECE 471 Embedded Systems Lecture 5

For technical support and service, please visit our support website at:

MEC-COM-M134. User s Manual

A B C D E F 0480 FE B F5 3B FC F3 E 1A 1D 2A 2D 3A 3D 4A 4D 5A 5D 6A 6D 7A 7D

Fics-RT1. User s Manual

Product Manual. USB BAY-4 Port Serial DB- 9 RS-232 Adapter with FTDI Chipset. Coolgear, Inc. Version 1.1 September 2017 Model Number: USBG-BAY4

ECE/CS 5780/6780: Embedded System Design

USB to RS-232/RS422/485. URK-228-I USB To Serial Operation Manual

BOARD LEVEL PRODUCTS OEM GPIB<->RS-232 INTERFACE BOARD GPIB

USB-ASC232. ASCII RS-232 Controlled USB Keyboard and Mouse Cable. User Manual

Xbee module configuration from a µcontroller

Learn how to communicate

CAN / RS485. Product Description. Technical Reference Note. Interface Adapter. Special Features

USART. USART stands for Universal Synchronous Asynchronous Receiver Transmitter. Full-duplex NRZ asynchronous serial data transmission

Software Architecture Document: Addendum

Informatics for industrial applications

8051 Microcontrollers

SC68C652B. 1. General description. 2. Features

a16450 Features General Description Universal Asynchronous Receiver/Transmitter

Serial Communication. Simplex Half-Duplex Duplex

PCIe Card Selection Guide. PCIe-CAN Card. PCIe-COM Card. Taiwan Pulse Motion Co.,Ltd. Bus Interface PCI Express x 1 LPE-C122 PCE-C122D PCE-C122T

TIME MACHINE Data Formats (Sep jkuo: extracted from the TIME MACHINE user manual)

PCI Express 16-Port Serial I/O Cards

LCD05 datasheet 1.0

Input-Output Organization

Module Introduction. PURPOSE: The intent of this module, is to explain several of the important features of Freescale s i.mx1 applications processor.

Programming in C++ 4. The lexical basis of C++

Homework 9: Software Design Considerations

Software Documentation

ECE 571 Advanced Microprocessor-Based Design Lecture 3

Transcription:

ECE 598 Advanced Operating Systems Lecture 6 Vince Weaver http://www.eece.maine.edu/~vweaver vincent.weaver@maine.edu 3 February 2015

Announcements Homework #2 will be released shortly Raspberry Pi 2??? 1

BCM2835 UART on the Pi Section 13 of the Peripheral Manual Two UARTS. Mini (pc reg layout compat) and ARM PL011. We use the latter. No IrDA or DMA support, no 1.5 stop bits. Separate 16x8 transmit and 16x12 receive FIFO memory. Why 12? 4 bits of error info on receive. overrun (FIFO overflowed), break (data held low over full time), parity, frame (missing stop bit). 2

Programmable baud rate generator. start, stop and parity. These are added prior to transmission and removed on reception. False start bit detection. Line break generation and detection. Support of the modem control functions CTS and RTS. However DCD, DSR, DTR, and RI are not supported. Programmable hardware flow control. 3

Fully-programmable serial interface characteristics: data can be 5, 6, 7, or 8 bits even, odd, stick, or no-parity bit generation and detection 1 or 2 stop bit generation baud rate generation, dc up to UARTCLK/16 1/8, 1/4, 1/2, 3/4, and 7/8 FIFO interrupts 4

BCM2835 UART Can map to GPIO14/15 (ALT0), GPIO36/37 (ALT2), GPIO32/33 (ALT3) Base ni 0x20201000, 18 registers 5

Hooking up Cable to Pi Linux should come with a driver. May need to download PL2303 OSX or Windows driver. Some useful documentation: http://www.adafruit.com/products/954 https://learn.adafruit.com/adafruits-raspberry- Adapter will provide 5V to your board, won t even need to USB-micro cable. Hookup: 6

Red (5V) to pin 2, Black (GND) to pin 6 White (TXD) to pin 8 (GPIO14) Green (RXD) to pin 10 ( GPIO15) 7

Inline Assembly Can write assembly code from within C gcc inline assembly is famously hard to understand/write volatile keyword tells compiler to not try to optimize the code within static inline void delay ( int32_t count ) { asm volatile (" delay_ %=: subs %[ count ], %[ count ], #1; " " bne delay_ %=\ n" : : [ count ]"r"( count ) : "cc"); } 8

: output operands = means write-only, + is read/write r=general reg : input operandss : clobbers list of registers that have been changed memory is possible, as is cc for status flags can use %[X] to refer to reg X that can then use [X]"r"(x) to map to C variable 9

MMIO Memory mapped I/O As opposed to separate I/O space (as found on x86 and some other processors) For HW#2 instead of using array for MMIO access, we will use inline assembly 10

UART Interrupts Supports one interrupt (UARTRXINTR), which is signaled on the OR of the following interrupts: 1. UARTTXINTR if FIFO less than threshold or (if FIFO disabled) no data present 2. UARTRTINTR if receive FIFO crosses threshold or (if FIFO disabled) data is received 3. UARTMSINTR which can be caused by UARTCTSINTR (change in nuartcts) UARTDSRINTR (change in the nuartdsr) 11

4. UARTEINTR (error in reception) UARTOEINTR (overrun error) UARTBEINTR (break in reception) UARTPEINTR (parity error) UARTFEINTR (framing error) 12

UART Init Code /* Disable UART */ mmio_write ( UART0_CR, 0x0 ); /* Setup GPIO pins 14 and 15 */ /* Disable the pull up/ down on pins 14 and 15 */ /* See the Peripheral Manual for more info */ /* Configure to disable pull up/ down and delay for 150 cycles */ mmio_write ( GPIO_GPPUD, GPIO_GPPUD_DISABLE ); delay (150); /* Pass the disable clock to GPIO pins 14 and 15 and delay */ mmio_write ( GPIO_GPPUDCLK0, (1 << 14) (1 << 15)); delay (150); /* Write 0 to GPPUDCLK0 to make it take effect */ mmio_write ( GPIO_GPPUDCLK0, 0 x0 ); /* Clear pending interrupts. */ mmio_write ( UART0_ICR, 0 x7ff ); 13

/* Set integer & fractional part of baud rate. */ /* Divider = UART_CLOCK /(16 * Baud ) */ /* Fraction part register = ( Fractional part * 64) + 0.5 */ /* UART_CLOCK = 3000000; Baud = 115200. */ /* Enable FIFO */ /* And 8 N1 (8 bits of data, no parity, 1 stop bit */ mmio_write ( UART0_LCRH, UART0_LCRH_FEN UART0_LCRH_WLEN_8BIT ); /* Mask all interrupts. */ mmio_write ( UART0_IMSC, UART0_IMSC_CTS UART0_IMSC_RX UART0_IMSC_TX UART0_IMSC_RT UART0_IMSC_FE UART0_IMSC_PE UART0_IMSC_BE UART0_IMSC_OE ); /* Enable UART0, receive, and transmit */ mmio_write ( UART0_CR, UART0_CR_UARTEN UART0_CR_TXE UART0_CR_RXE ); 14

void uart_putc ( unsigned char byte ) { UART Send byte /* Check Flags Register */ /* And wait until FIFO not full */ while ( mmio_read ( UART0_FR ) & UART0_FR_TXFF ) { } } /* Write our data byte out to the data register */ mmio_write ( UART0_DR, byte ); 15

unsigned char uart_getc ( void ) { UART Receive byte /* Check Flags Register */ /* Wait until Receive FIFO is not empty */ while ( mmio_read ( UART0_FR ) & UART0_FR_RXFE ) { } /* Read and return the received data */ /* Note we are ignoring the top 4 error bits */ } return mmio_read ( UART0_DR ); 16

Escape Codes VT102/Ansi Historical reasons, oldest terminals. Used to be hundreds of types supported (see termcap file) Color, cursor movement The escape character (ASCII 27) used to specify extra commands 17

Typewriters Carriage Return vs Linefeed Carriage return ( r), go to beginning of line Linefeed ( n), move down a row DOS uses both CRLF UNIX uses just LF 18

MAC uses just CR Which does your terminal program use? 19

Writing header files Including with versus <> 20

int printk ( char * string,...) { va_list ap; va_start (ap, string ); while (1) { if (* string ==0) break ; Writing printk if (* string == % ) { string ++; if (* string == d ) { string ++; x= va_arg (ap, int ); 21

Scanning ATAGS List of variables passed by bootloader. A standard. We mostly care about getting memory size. Size, Tag-type, additional Located traditionally at 0x800 but you should really check r3 for addr. Starts with ATAG CORE 22

Ends with ATAG NONE We wants ATAG MEM and maybe ATAG CMDLINE on Raspberry Pi. 23

Read into buffer Parsing Command Line When CR or LF happens, pass buffer to string that handles things. Complications: backspace? UNIX challenge Writing a parser, how? W/o strlen, strtok, etc? 24