A Scheme Interpreter on a Microcontroller

Similar documents
ARM HOW-TO GUIDE Interfacing Switch with LPC2148 ARM

Lab Experiment 9: LCD Display

ARM HOW-TO GUIDE Interfacing Stepper Motor with LPC2148

AN LPC2138 extreme power down application note. Document information. LPC2138, extreme power down

ARM HOW-TO GUIDE Interfacing Buzzer with LPC2148 ARM

ARM HOW-TO GUIDE Interfacing Relay with LPC2148 ARM

Adafruit 1-Wire GPIO Breakout - DS2413

AN Entering ISP mode from user code. Document information. ARM ISP, bootloader

ECE251: Thursday November 8

An Example of using Keil uvision3 for creating Keil ARM s Project File

ARM HOW-TO GUIDE Interfacing GLCD with LPC2148 ARM

GRAPHICS LCD INTERFACING WITH 8051

I2C on the HMC6352 Compass

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

BV4218. I2C-LCD & Keypad. Product specification. December 2008 V0.a. ByVac 2006 ByVac Page 1 of 9

ECE251: Intro to Microprocessors Name: Solutions Mid Term Exam October 4, 2018

Topic 10: Instruction Representation

Experiment 1. Development Platform. Ahmad Khayyat, Hazem Selmi, Saleh AlSaleh

CS 241 Data Organization Binary

STM32F100RB processor GPIO notes rev 2

275 to 550 MHz Frequency Synthesizer

AN PN5180 Secure firmware update. Application note COMPANY PUBLIC. Rev December Document information

ARM HOW-TO GUIDE Interfacing GLCD with LPC2148 ARM

ECE2049 Homework #2 The MSP430 Architecture & Basic Digital IO (DUE Friday 9/8/17 at 4 pm in class)

Development of ET-ARM STAMP LPC2119 Program with GCCARM and Keil cvision3 Development of ET-ARM STAMP LPC2119 Program with GCCARM and Keil uvision3

CSCI 2212: Intermediate Programming / C Chapter 15

are Softw Instruction Set Architecture Microarchitecture are rdw

ECE 598 Advanced Operating Systems Lecture 4

Survey. Motivation 29.5 / 40 class is required

C - Basics, Bitwise Operator. Zhaoguo Wang

ARM Embedded Development Using Oberon-07

QUICK START GUIDE FOR DEMONSTRATION CIRCUIT 1110 SINGLE, PARALLEL, IOUT, 16-BIT DAC

Computer Architecture

Graphical LCD Display Datasheet EB

Disk Operating System

Application Note: AN00189 Using QuadSPI for application overlay data

Efficient Hardware Arithmetic in Common Lisp

Topic 3. ARM Cortex M3(i) Memory Management and Access. Department of Electronics Academic Year 14/15. (ver )

Arithmetic and Bitwise Operations on Binary Data

Serial to LANC Adapter User s Guide

Thus needs to be a consistent method of representing negative numbers in binary computer arithmetic operations.

ELEC 3040/3050 Lab 5. Matrix Keypad Interface Using Parallel I/O

RFID A1 Module User Manual V1.183

DIGITAL COMPASS SOLUTION

Project 15 - Reading a keypad with the Raspberry Pi

1. Introduction to Assembly Language

Arithmetic and Bitwise Operations on Binary Data

Futaba MDM166A display

TPMC815 ARCNET PMC. User Manual. The Embedded I/O Company. Version 2.0. Issue 1.2 November 2002 D

LPC-P1227 development board USER S MANUAL Initial release, March 2012 Designed by OLIMEX Ltd, 2011

Instruction Set Architectures Part I: From C to MIPS. Readings:

Review of Last Lecture. CS 61C: Great Ideas in Computer Architecture. MIPS Instruction Representation II. Agenda. Dealing With Large Immediates

2TB DATA SHEET Preliminary

AN Full-duplex software UART for LPC2000. Document information

SRS501 User s manual

DPScope SE Programming Interface Description

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design

CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS

LCD board. EB005

Experiment 3. Interrupts. Hazem Selmi, Ahmad Khayyat

ECE 206, Fall 2001: Lab 3

CS 61c: Great Ideas in Computer Architecture

User s Guide. IP-201 I2C Bus Multiplexer Board Revision 1. Micro Computer Control Corporation

AN LPC1700 secondary USB bootloader. Document information. LPC1700, Secondary USB Bootloader, ISP, IAP

CSE 220: System Fundamentals I Unit 14: MIPS Assembly: Multi-dimensional Arrays. Kevin McDonnell Stony Brook University CSE 220

Evaluation Board Quick Start. PE FI-1.x

QSFP Breakout. Data Sheet. Datasheet QSFP Breakout. 1 Overview. Table of Contents. 2 Features

Computer Organization & Systems Exam I Example Questions

Embedded Development Platform

Introduction to Programming

Grundlagen Microcontroller Processor Core. Günther Gridling Bettina Weiss

SPI (Serial & Peripheral Interface)

Avnet S6LX16 Evaluation Board and Maxim DAC/ADC FMC Module Reference Design

Evaluation Board Quick Start. PE FI-2.x

ARM HOW-TO GUIDE Interfacing 7SEG with LPC2148 ARM

OM13071 LPCXpresso824-MAX Development board

Exam 1. Date: February 23, 2016

SLCD1-IC Serial LCD Processor

Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras

VGA multimedia board

LABORATORY MANUAL EMBEDDED SYSTEMS LABORATORY. M. Tech I Year I Sem R15 DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGG.

Embedded Systems. School of Computer Science

Introduction to Micro-controllers. Anurag Dwivedi

Grasshopper always wrong in argument with Chicken. - Book of Chan

ArduCAM-M-2MP Camera Shield

Before Class Install SDCC Instructions in Installing_SiLabs-SDCC- Drivers document. Solutions to Number Systems Worksheet. Announcements.

Part I: LPC2148 USB Bootloader Overview

VN310 Hardware Integration

Microcontrollers. What is a Microcontroller. Setting up. Sample First Programs ASCII. Characteristics Basic Stamp 2 the controller in the Boe Bot

Instruction Sets: Characteristics and Functions

SAB-TFBGAxxx Quick Start Guide. This document applies to SAB-TFBGA100, SAB-TFBGA180, and SAB-TFBGA208.

ProductionLine Testers, Inc. P#: SMU-410 USER GUIDE

Solution to the Problems and Questions

Announcements Homework #3 due today. Ports. Outline for Today C8051 SFRs & Port I/O Worksheet #4 - simple I/O code. Using Ports

RS 232 LED displays Decoder for BxxSC LED Series BIFC. Dimensions (mm) A

How to program the Fast Amplifiers

TFT LCD multimedia board with touchscreen

TIP550. Optically Isolated 8/4 Channel 12-bit D/A. Version 1.2. User Manual. Issue October 2009

AN5179. RS232 communications with a terminal using the STM8 Nucleo-64 boards. Application note. Introduction

LPC1768 Industrial Reference Design Platform System Development Kit Version 1.3. May 2009

Transcription:

1 A Scheme Interpreter on a Microcontroller repl accessible through serial communication runs Armpit Scheme interpreter +/- R5RS compliant Hands on: have the board execute a factorial function notice any non-r5rs compliance?

2 Essential μc-specific Scheme extensions binary operations binary literals base to format 32-bit number in (number->string (logior #b1100 #b1010) 2) ; -> "00000000000000000000000000001110" (number->string (logxor #b1100 #b1010) 2) ; -> "00000000000000000000000000000110" (number->string (logand #b1100 #b1010) 2) ; -> "00000000000000000000000000001000" (number->string (lognot #b1100) 2) ; -> "11111111111111111111111111110011" (number->string (ash #b1100 4) 2) ; -> "00000000000000000000000011000000" (number->string (ash #b1100-2) 2) ; -> "00000000000000000000000000000011" arithmetic shift direction

3 Essential μc-specific Scheme extensions reading and writing to and from memory optional arguments (read memory-location offset number-of-bytes) (write value memory-location offset number-of-bytes) base address added to base address example (read #xe002800c 0) = (define BASE #xe0028000) (read BASE #x0c)

4 Interfacing with the Physical World microcontroller has two general-purpose input-output (GPIO) ports each port has 32 pins each pin corresponds to set of registers 32-bit physical variables in microcontroller referred to by address mapped to EXT1 and EXT2 connectors on development board listed in development board datasheet 2 extra pins on flat ribbon to provide power

5 Controlling Pins on Ports base addresses of port (define GPIO_0 #xe0028000) ; IO0 port (define GPIO_1 #xe0028010) ; IO1 port pin controlling registers (define IOPIN #x00) ; IOxPIN register offset (define IOSET #x04) ; IOxSET register offset (define IODIR #x08) ; IOxDIR register offset (define IOCLR #x0c) ; IOxCLR register offset addresses and offsets can be found in the data sheet (cfr. references on last slide)

6 Configuring Pin Direction Setting P0.06 to output (define pin6 (ash 1 6)) (write pin6 GPIO_0 IODIR) Everything else is input now!! Using logical or to set P0.06 respecting previous settings (define previous-dir (read port IODIR)) (write (logior previous-dir (ash 1 6)) GPIO_0 IODIR) Abstracted away into functions (define (set-dir! port pin) (write (logior (read port IODIR) pin) port IODIR)) (define (set-dir-input! port pin) (write (logand (read port IODIR) (lognot pin)) port IODIR))

7 Producing High Value On Pin Setting P0.06 to high = writing 1 << 6 (write (ash 1 6) gpio0 IOSET) Does not change other pins Abstracted away away into a function (define (set-pin! port pin) (write pin port IOSET)) Setting a pin to low is very similar (define (clear-pin! port pin) (write pin port IOCLR))

8 Exercise: Blinking LED What do we need to do: 1. set target pin direction 2. set pin to high 3. wait for a while 4. set pin to low 5. wait for a while 6. repeat from 2

8 Exercise: Blinking LED What do we need to do: 1. set target pin direction 2. set pin to high 3. wait for a while 4. set pin to low 5. wait for a while 6. repeat from 2 (define led-pin (ash 1 6)) (set-dir! GPIO_0 led-pin)

8 Exercise: Blinking LED What do we need to do: 1. set target pin direction 2. set pin to high 3. wait for a while 4. set pin to low 5. wait for a while 6. repeat from 2 (define led-pin (ash 1 6)) (set-dir! GPIO_0 led-pin) (set-pin! GPIO_0 led-pin)

8 Exercise: Blinking LED What do we need to do: 1. set target pin direction 2. set pin to high 3. wait for a while 4. set pin to low 5. wait for a while 6. repeat from 2 (define led-pin (ash 1 6)) (set-dir! GPIO_0 led-pin) (set-pin! GPIO_0 led-pin) (clear-pin! GPIO_0 led-pin)

8 Exercise: Blinking LED What do we need to do: 1. set target pin direction 2. set pin to high 3. wait for a while 4. set pin to low 5. wait for a while 6. repeat from 2 (define led-pin (ash 1 6)) (set-dir! GPIO_0 led-pin) (set-pin! GPIO_0 led-pin) (clear-pin! GPIO_0 led-pin) (wait-us 1000000) ; this will wait for that ; many μsecs, one second

9 References Introduction to Electronics http://machineproject.com/2007/06/02/electronics-for-artists/ http://library.thinkquest.org/16497/intro/index.html http://openbookproject.net//electriccircuits/ Armpit Scheme Interpreter http://armpit.sourceforge.net/ Datasheet NXP LPC2214 Microcontroller http://www.nxp.com/acrobat_download/usermanuals/ UM_LPC2114_2124_2212_2214_2.pdf Datasheet Olimex H-2214 Develoment Board http://www.olimex.com/dev/lpc-h2214.html