Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lab 3 General MIDI Explorer with Record/Playback

Similar presentations

Presentation on theme: "Lab 3 General MIDI Explorer with Record/Playback"— Presentation transcript:

1 Lab 3 General MIDI Explorer with Record/Playback
Getting Started updated 11/08 by Felipe Vilas-Boas and W. Burleson

2 Where are we? Lab 0 MIDI Receiver Lab 1 Cache Simulator in C
Verilog/Quartus, Breadboarding, GoLogic, MIDI-Ox Lab 1 Cache Simulator in C C programming, data structures Cache architecture and analysis Lab 2 Pipelined Machine Pipeline architecture and analysis Lab 3 General MIDI Explorer with Record/Playback Microcontroller programming C Assembly

3 Objectives Exposure to microcontroller programming
Assembly Language (ASM) Talking to A/D converter Talking to Timer Talking to UART Compiled Language (C) Data Structure in Memory Continuation of MIDI theme Serial communication Notes and instruments FUN! A complete system with input, output, storage

4 Requirements C Program ASM Program Send & Receive MIDI Messages
Play and Recording Modes Store and Replay MIDI Messages ASM Program Vary speed of messages via hex switch Instrument / Note / Velocity via photo cells Change channels between Percussion & Instrument

5 Relevant AVR Components
C Program Data EEPROM (Storage) USART (Communication) ASM Program Timer1 (Counter) ADC (Analog to Digital Converter) Will manipulate these components using AVR assembly.

6 AVR Assembly Commands similar to MIPS
ldi, breq, andi, lsr, rsr, etc. ‘in’/’out’ used when working with I/O ports Can ‘rjmp’ using tags (no offsets to worry about) There are some differences though… sbic, neg, cbi, etc.

7 Setup Example (AVR) Setup Example
.include "“ (Include system file) .def Temp=R16 (Define R16 register) .org 0x (Where to begin)          rjmp RESET (Jump to RESET) RESET:

8 Stack Pointer You must initialize the stack pointer if you wish to return from jumps… Set stack pointer         ldi        Temp, 0x65         out        SPL, Temp

9 Setup Example (C) Setup Example
#include <avr/io.h> (Include system file) int main() { int data; DDRA = 0xFF; (PORTA output) DDRB = 0x00; (PORTB input) PORTA = 0x55; (Output 0x55 or b ) data = PINB; (Store input values) }

10 Timer1 Timer1 is the 16-bit counter on the AVR
Will count overflows of Timer1 in order to gauge transmission time. Good to set counter prescalar to 1024 Choose 1024 prescalar for Timer1 ldi        Temp, 0x05 out        TCCR1B, Temp

11 USART Must initialize with desired baud rate and frame format
Must be initialized in both C and ASM MIDI Baud rate : kbps Want start/stop bits and 8 data bits Read data sheet

12 ADC General AVR ADC reading process: Enable ADC Specify pin to read
Call for conversion Check completion bit Copy data to intermediate register

13 Photo

For Note on : 0x90 / 0x?? / 0x?? For Note off : 0x80 / 0x?? / 0x?? For Inst. Change : 0xC0 / 0x?? For Note on Perc. Chan : 0x99 / 0x?? / 0x?? Max data value for MIDI NOTE / VEL should be 0x7F ADC can output up to 0xFF

15 What Now? Every time Timer1 overflows, a flag will be triggered. Use this to time transmission. Package MIDI messages correctly Three Byte Clusters (Status/Note/Velocity) MIDI On and Off Messages

16 Hints Datasheet is extremely helpful Timer in ASM can be tricky
Both C and ASM Timer in ASM can be tricky Send Dummy Messages to test timing C program slightly simpler Start with C to understand the AVR ASM can be broken into two pieces

Download ppt "Lab 3 General MIDI Explorer with Record/Playback"

Similar presentations

Ads by Google