16F84 MIDI Decoder

 

Modifying Receive Channel

 

Technical note for Callipygian Sight and Sound  MIDI PIC Project

 

Robert Swirsky, November 11, 2004

 

The software has the channel hard-coded to MIDI channel 10. To change to a different channel, you must change the line of code in shown below in red

 

; wait 32 clocks and see if we have a STOP bit (FRAMING ERROR CHECK)

;     8 bits x 32 cycles + 10 = 266 clocks at this point

 

frame_chk:

      movf  ichar, w          ; 266

      xorlw     0x99          ; 267

      btfss STATUS, Z         ; 268

      goto  inc_state         ; 269, 270

      clrf  serial_state      ; 270 (we have a 0x99! Set the state to 1...

                              ; ...by zeroing it here and incrementing below

inc_state:

      incf  serial_state, f         ; 271

 

 

That code is checking for a command starting with hex 99 which is MIDI for “Note on, Channel 10”.  The first digit,

 

            99

 

means “Note On”. We want to leave that alone.

 

The second digit

 

            99

 

means channel 10. (Why 10? Because MIDI calls 0 “Channel 1”)

 

To change the channel to MIDI 1-16 use the corresponding hex digit

 

MIDI CHANNEL

HEX DIGIT

1

0

2

1

3

2

4

3

5

4

6

5

7

6

8

7

9

8

10

9

11

A

12

B

13

C

14

D

15

E

16

F

 

So if you want this PIC to respond to channel 13, you want hex digit “C”. Replace that line of code with

 

xorlw     0x9C          ; 267

 

…recompile, link, and burn, and you’re in business!

 

MIDI Pic Project Home Page