1 / 16

Lab 3 General MIDI Explorer with Record/Playback

Lab 3 General MIDI Explorer with Record/Playback. Getting Started updated 11/08 by Felipe Vilas-Boas and W. Burleson. Where are we?. Lab 0 MIDI Receiver Verilog/Quartus, Breadboarding, GoLogic, MIDI-Ox Lab 1 Cache Simulator in C C programming, data structures

lona
Download Presentation

Lab 3 General MIDI Explorer with Record/Playback

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab 3General 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 • Verilog/Quartus, Breadboarding, GoLogic, MIDI-Ox • Lab 1 Cache Simulator in C • C programming, data structures • Cache architecture and analysis • Lab 2 Pipelined Machine • C programming, data structures • 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 • Talking to UART • Continuation of MIDI theme • Serial communication • Notes and instruments • FUN! A complete system with input, output, storage

  4. Requirements • C 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) • USART (Communication) • 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 "m32def.inc“ (Include system file) .def Temp=R16 (Define R16 register) .org 0x0000 (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 0b01010101) 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 : 31.25 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

  14. MIDI Message Format • STATUS / NOTE / VELOCITY • 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 • 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

More Related