ECE 353 Lab 4. General MIDI Explorer. Professor Daniel Holcomb Fall 2015

Similar documents
Robosoft Systems in association with JNCE presents. Swarm Robotics

CN310 Microprocessor Systems Design

Lab Course Microcontroller Programming

Getting Started with STK200 Dragon

Microcontroller basics

AVR XMEGA TM. A New Reference for 8/16-bit Microcontrollers. Ingar Fredriksen AVR Product Marketing Director

C Programming in Atmel Studio 7 Step by Step Tutorial

Programming Microcontroller Assembly and C

ECE 353 Lab 4. MIDI Receiver in Verilog. Professor Daniel Holcomb UMass Amherst Fall 2016

An FTDI connection: The ATtiny microcontrollers don t have a hardware UART External Crystal header pins for an optional crystal

Introduction to Arduino. Wilson Wingston Sharon

Microcontroller basics

Programming Microcontroller

TEVATRON TECHNOLOGIES PVT. LTD Embedded! Robotics! IoT! VLSI Design! Projects! Technical Consultancy! Education! STEM! Software!

Embedded programming, AVR intro

M16C/62P QSK QSK62P Plus Tutorial 1. Software Development Process using HEW4

Rapidly Developing Embedded Systems Using Configurable Processors

EE 354 Fall 2015 Lecture 1 Architecture and Introduction

Development Tools. 8-Bit Development Tools. Development Tools. AVR Development Tools

The Atmel ATmega328P Microcontroller

Mega128-DEVelopment Board Progressive Resources LLC 4105 Vincennes Road Indianapolis, IN (317) (317) FAX

AVRUSBPRG1 USB AVR IN SYSTEM PROGRAMMER

INTERFACING HARDWARE WITH MICROCONTROLLER

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100)

Introduction to Embedded Systems

Microprocessors And Microcontrollers (Practical)

Installation and Maintenance

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

CMS-8GP32. A Motorola MC68HC908GP32 Microcontroller Board. xiom anufacturing

Embedded Systems. PIC16F84A Internal Architecture. Eng. Anis Nazer First Semester

Software debouncing of buttons

Embedded Systems Programming. ETEE 3285 Topic HW3: Coding, Compiling, Simulating

Introduction USART & AVR EVK1100

Lab 2: Basic Assembly Programming and Debugging using AVR Studio. Due: December 13, 2011

Mega128-Net Mega128-Net Mega128 AVR Boot Loader Mega128-Net

IAS0430 MICROPROCESSOR SYSTEMS

Distributed Real- Time Control Systems

,$5$SSOLFDWLRQ1RWH$95 (IILFLHQWSURJUDPPLQJRI$WPHO V $95 PLFURFRQWUROOHUV

Robotics Training Module ABLab Solutions

EE4380 Microprocessor Design Project

EMBEDDED SYSTEMS COURSE CURRICULUM

ATmega128. Introduction

SYSTEM DESIGN SPECIFICATIONS ZIGBEE BASIC SYSTEM

8051 Microcontroller

PART 1 : MR-162. PART 2 : CPU Board. PART 3 : Software Tools. PART 4 : Compile and Download. 1. Introduction 2. Features

Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso

The Atmel ATmega168A Microcontroller

Clock and Fuses. Prof. Prabhat Ranjan Dhirubhai Ambani Institute of Information and Communication Technology, Gandhinagar

ET-BASE AVR ATmega64/128


INTERRUPTS in microprocessor systems

Embedded Systems Lab Lab 1 Introduction to Microcontrollers Eng. Dalia A. Awad

Microcontroller systems Lec 2 PIC18LF8722 Microcontroller s s core

3.3V regulator. JA H-bridge. Doc: page 1 of 7

Network Embedded Systems Sensor Networks Fall Hardware. Marcus Chang,

Lecture 14. Ali Karimpour Associate Professor Ferdowsi University of Mashhad

Emulating an asynchronous serial interface (USART) via software routines

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

Introduction to Microcontroller Apps for Amateur Radio Projects Using the HamStack Platform.

Embedded Systems. Software Development & Education Center. (Design & Development with Various µc)

University of Florida EEL 3744 Spring 2018 Dr. Eric M. Schwartz. Good luck!

ECE 353 Lab 4. MIDI Receiver in Verilog. Professor Daniel Holcomb UMass Amherst Fall 2017

Lesson 5 Arduino Prototype Development Platforms. Chapter-8 L05: "Internet of Things ", Raj Kamal, Publs.: McGraw-Hill Education

Layman definition: Gadgets and devices Technical definition: Self-controlled devices Usually, such systems consist of I/O (input/output) devices such

COMP2121 Introductory Experiment

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

PIC Microcontroller Introduction

Blobo Clone Angry Birds Toy Upgrade. Schedule of the project and log of work done

Distributed Real-Time Control Systems. Module 3 Hardware for Real Time Distributed Control Systems

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet Example Application...

Figure 1.1: Some embedded device. In this course we shall learn microcontroller and FPGA based embedded system.

Laboratory Exercise 3 Comparative Analysis of Hardware and Emulation Forms of Signed 32-Bit Multiplication

SKP16C26 Tutorial 1 Software Development Process using HEW. Renesas Technology America Inc.

EE 308: Microcontrollers

AVR Microcontrollers Architecture

RISC-V Core IP Products

Blobo Clone Angry Birds Toy Upgrade. Requirement and implementation specification and test plan

OUTLINE. STM32F0 Architecture Overview STM32F0 Core Motivation for RISC and Pipelining Cortex-M0 Programming Model Toolchain and Project Structure

acret Ameya Centre for Robotics & Embedded Technology Syllabus for Diploma in Embedded Systems (Total Eight Modules-4 Months -320 Hrs.

Quick Start Guide for the Turbo upsd DK3300-ELCD Development Kit- RIDE

MICROPROCESSOR BASED SYSTEM DESIGN

EE 308: Microcontrollers

The Freescale MC908JL16 Microcontroller

Microcontroller: CPU and Memory

PIC Microcontroller and

ARDUINO MEGA INTRODUCTION

Lab Objectives. 2. Preparations. 3. Signing in. 4. Examining the Host Environment. 5. Part A: Introduction to AVR Studio. 5.

Goal: We want to build an autonomous vehicle (robot)

COMP2121 Experiment 4

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet... 4

AVR XMEGA Product Line Introduction AVR XMEGA TM. Product Introduction.

ECE3120: Computer Systems Hardware & Software Development Tools

Introduction to general architectures of 8 and 16 bit micro-processor and micro-controllers

Arduino Internals. Dale Wheat. Apress

Lab 1 Introduction to Microcontroller

Embedded Systems and Software

Module 2: Introduction to AVR ATmega 32 Architecture

C Language Programming, Interrupts and Timer Hardware

Lesson 14. Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27)

MegaAVR-DEVelopment Board Progressive Resources LLC 4105 Vincennes Road Indianapolis, IN (317) (317) FAX

Transcription:

ECE 353 Lab 4 General MIDI Explorer Professor Daniel Holcomb Fall 2015

Where are we in Course Lab 0 Cache Simulator in C C programming, data structures Cache architecture and analysis Lab 1 Heat Flow Modeling C programming, data structures Lab 2 Pipelined Machine C programming, data structures Pipeline architecture and analysis Lab 3 MIDI Receiver Hardware design Proper Verilog coding Functional Simulation, GoLogic, MIDI-Ox Lab 4 General MIDI Explorer with Record/Playback Microcontroller programming in C Breadboarding and Debugging ECE353: 2 Computer Systems Lab 1 Kundu/Holcomb

Microprocessors, Microcontrollers, Programmable Logic Microprocessors are higher performance capable and larger memory From 50MHz to GHz FPGA systems often contain CPUs in softcore (synthesized) or hardcore (part of die) format but can also contain logic blocks for other hardware, e.g., state machines, etc 45-65 nm FPGAs (Virtex 5-7) can achieve high performance. Microcontrollers are more limited in functionality and often do not include support for virtual memory and caches Up to 50MHz Soft core Hard core with builtin Transceivers Discrete PHY Tx Rx Tx Rx ECE353: 3 Computer Systems Lab 1 Kundu/Holcomb

Lab 4 Objectives Build a complete system Record MIDI packets from computer when prompted Store on breadboard (modify them) Playback to computer when prompted Hear music Record Playback ATmega32 MIDI Computer ECE353: 4 Computer Systems Lab 1 Kundu/Holcomb

Lab 4 Objectives Exposure to microcontroller programming vs. design of hardware Compiled Language (C) Data Structure in Memory Low level interaction with hardware components Continuation of MIDI theme Serial communication Notes and instruments Intended to be a FUN project ECE353: 5 Computer Systems Lab 1 Kundu/Holcomb

ATmega32 AVR 16MHz CMOS 8-bit microcontroller with AVR RISC instruction set 32 general purpose registers 32KB of Flash 2Kb internal SRAM 1KB E2PROM 100k erase cycles 8 and 16 bit counters USART/SPI/I2C 8-channel 10-bit ADC JTAG 4 8-bit I/O ports mw power Power-on Reset Circuitry that detects when power-on and resets all registers Different than Lab3 ECE353: 6 Computer Systems Lab 1 Kundu/Holcomb

Flexible Tool. Many Configurations. Use Carefully www.wengerna.com ECE353: 7 Computer Systems Lab 1 Kundu/Holcomb

Lab 4 Requirements Part 1: Send & Receive MIDI Messages Play and Recording Modes Store and Replay MIDI Messages HW Components Data EEPROM (Storage) USART (Communication) Timer1 (Counter) Part 2: (optional for extra credit) Use hex switch and photo cells Vary speed of messages or repetition Change note or velocity More GPIO ADC (Analog to Digital Converter) ECE353: 8 Computer Systems Lab 1 Kundu/Holcomb

Schematic Optional photocell Record and playback switches not shown ECE353: 9 Computer Systems Lab 1 Kundu/Holcomb

ECE353: 10 Computer Systems Lab 1 Kundu/Holcomb

Required Part of Lab: Develop, program AVR through JTAG, for: Getting MIDI messages through MIDI OX from the PC serially Similar to Lab 3 but using software AVR Studio and AVR gcc compiler Configure USART to read MIDI bytes Once messages received in AVR Store in E2PROM if switch set to Record Compress before storing, decompress after Use any algorithm you find suitable Record timing also so that you can replay exactly the same way Playback when prompted ECE353: 11 Computer Systems Lab 1 Kundu/Holcomb

Compression Why compress? Store more data in same persistent memory Persistent data limited in # of erase cycles Save on bandwidth when communicating Lossless compression (LZ, Huffman, RLE): Decompress and get the same data, bit - for - bit Lossy compression (JPEG, ): Decompress and get something similar Tradeoff between quality and compression Domain specific data patterns can be exploited ECE353: 12 Computer Systems Lab 1 Kundu/Holcomb

Run Length Encoding Simple lossless encoding of repeating patterns Example: Imagine a stream of bits with many 0s and 1s Source: 000000000111111110001111111 RLE Version: 90813071 Limit maximum sequence value to avoid too much overhead for very random sequences. limit to maximum 16 repetition of 1s or 0s: represent with 4 bits 1001(0)1000(1)0011(0)0111(1) for above sequence Compression ratio is 27/20 What is best possible compression ratio in this scheme? Provide sequence that realizes this ratio What is the worst possible compression ratio in this scheme? Provide a sequence that realizes this ratio ECE353: 13 Computer Systems Lab 1 Kundu/Holcomb

Pseudocode of a Possible Implementation Configure timers/usart/interrupts/etc While (1) { If (recording) { USART_Read() Compress EEPROM_Write() } If (playing) { EEPROM_Read() Decompress USART_Write() } } ECE353: 14 Computer Systems Lab 1 Kundu/Holcomb

Figure Out How To Initialize the USART Set baud rate for MIDI (remember clock divider from lab 3?) Enable the receiver and transmitter Initialize to 8 data bits, 1 stop, and 1 stop bit Create functions for receive, transmit, and flush USART Create functions to read and write E2PROM Work with timers and interrupts Use 16-bit counter and generate interrupts for overflows; need to setup ISR (interrupt service routine) Main function Can use LEDs to debug, try something simple first ATmega datasheet is your friend in this lab All information needed is found there, including sample code ECE353: 15 Computer Systems Lab 1 Kundu/Holcomb

Using the USART UCSRA/UCSRB/UCSRC (USART Control Status Register A/B/C) UBRRH/UBRRL (USART Baud Rate Register High/Low) Lots of bit-set and bit-check operations ECE353: 16 Computer Systems Lab 1 Kundu/Holcomb

Suggestions for building project incrementally Write simple sketch of code Verify that playback/record switches lead to the expected points in code Verify that USART receives MIDI correctly Use watch window or light up LEDs (just like lab 3) Verify that USART correctly sends MIDI to PC Start by sending hard-coded constants Verify functions for reading and writing EEPROM Simple test routine applying a few values Then worry about compression ECE353: 17 Computer Systems Lab 1 Kundu/Holcomb

Example Code // blinky.c #include <avr/io.h> // Standard AVR header #include <avr/delay.h> // Delay loop functions int main(void) { DDRA = 0xFF; // PORTA is output while (1) { for (int i=1; i<=128; i*=2) { PORTA = i; _delay_loop_2(30000); } for (int i=128; i>1; i/=2) { PORTA = i; _delay_loop_2(30000); } } // end while } ECE353: 18 Computer Systems Lab 1 Kundu/Holcomb

Example Code #include <avr/io.h> int main(void) { int data; DDRA = 0xFF; (PORTA output) DDRB = 0x00; (PORTB input) PORTA = 0x55; (Output 0x55 or 0b01010101) data = PINB; (Store input values from port B) } ECE353: 19 Computer Systems Lab 1 Kundu/Holcomb

Optional Part: Integrate Additional Inputs Use three optical sensors connected to ADC inputs on AVR Move hand over sensor to change characteristics of playback Use 4-bit digital input from rotary hex switch What to do with these new inputs? Change note and velocity MIDI bytes Speed up or slow down playback Repeat notes during playback Or anything else you can think of Make sure to leave room on board if planning to do optional part of lab ECE353: 20 Computer Systems Lab 1 Kundu/Holcomb

General Advice Consult the Atmega32 datasheet Pin layouts Code examples Everything you need to manipulate the microcontroller for this project is here! Use the AVR studio debugger Check the value of pins and registers Single step through code to find source of problems Debug with logic analyzer and oscilloscope Check frequency of USART outputs on scope Use internet resources avrfreaks.net is a good resource for examples Start early and get help early if stuck ECE353: 21 Computer Systems Lab 1 Kundu/Holcomb

Build Process Board Assembly C Programming WinAVR AVR Studio (IDE) JTAG Programmer Testing In-Circuit Emulator MIDI-OX GoLogic Logic Analyzer Oscilloscope ECE353: 22 Computer Systems Lab 1 Kundu/Holcomb

WinAVR WinAVR is a set of development tools for Atmel AVR RISC microprocessors Programs written in C, compiled with GCC and avr-libc Open source, can be obtained at: winavr.sourceforge.net ECE353: 23 Computer Systems Lab 1 Kundu/Holcomb

AVR Studio Demo: Getting Started Open AVR Studio Select AVR GCC for the project type Type in a project title and choose project directory if necessary Click next and select the debugging platform (JTAG ICE) used to program the MCU as well as the MCU that you are using (ATmega32) Finish ECE353: 24 Computer Systems Lab 1 Kundu/Holcomb

AVR Studio Demo: Configure Project go to Project --> Configuration Options Choose the MCU clock frequency Under custom options, should see WinAVR for avr-gcc and make May need to add include directories and libraries if not seeing any external dependency files listed in project ECE353: 25 Computer Systems Lab 1 Kundu/Holcomb

AVR Studio Demo: Program Device Start Coding, then 1.build your project, and 2.connect to the MCU Once you connect to your MCU, erase the device and then load to flash memory the.hex file created in your project directory Use external clock (our 4MHz oscillator) Now ready to step through code! ECE353: 26 Computer Systems Lab 1 Kundu/Holcomb

In Circuit Emulator Debug code while it runs on ATmega32 Step through code one instruction at a time Breakpoints Can view current state of all registers using watch windows ECE353: 27 Computer Systems Lab 1 Kundu/Holcomb