Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "1 ECE 353 Lab 3 General MIDI Explorer with Record/Playback Getting Started updated 11/08 by Felipe Vilas-Boas and W. Burleson."— Presentation transcript:

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

2 2 ECE 353 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 3 ECE 353 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 4 ECE 353 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 5 ECE 353 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 6 ECE 353 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 7 ECE 353 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 8 ECE 353 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 9 ECE 353 Setup Example (C) Setup Example #include (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 10 ECE 353 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 11 ECE 353 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 12 ECE 353 ADC General AVR ADC reading process: Enable ADC Specify pin to read Call for conversion Check completion bit Copy data to intermediate register

13 13 ECE 353 Photo

14 14 ECE 353 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 15 ECE 353 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 16 ECE 353 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


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

Similar presentations


Ads by Google