Use the Sam2695 Dream MIDI chip: Difference between revisions

From F256 Foenix
Jump to navigationJump to search
(fleshed out a first draft of the sam2695 midi out page, midi in has to be filled in when more will be known)
 
m (link to datasheet)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Sam2695 Dream IC is in the F256K2 and F256Jr2 only ==
== Sam2695 Dream IC is in the F256K2 and F256Jr2 only ==


The MIDI specification from MIDI.org can be found in the organization's website https://midi.org/specs<br>
The SAM2695 datasheet can be found in this goodies github repo: https://github.com/Mu0n/F256MiscGoodies/blob/main/datasheets/SAM2695.pdf


There are many tutorials and overview of useful MIDI commands, here is one of them: https://www.cs.cmu.edu/~music/cmsip/readings/MIDI%20tutorial%20for%20programmers.html<br>
The MIDI specification from MIDI.org can be found in the organization's website https://midi.org/specs


Here's a reference list of General MIDI instrument by number: https://www.ccarh.org/courses/253/handout/gminstruments/<br>
There are many tutorials and overview of useful MIDI commands, here is one of them: https://www.cs.cmu.edu/~music/cmsip/readings/MIDI%20tutorial%20for%20programmers.html
 
Here's a reference list of General MIDI instruments by number: https://www.ccarh.org/courses/253/handout/gminstruments/ <br>
{| class="wikitable"
|+
!Register Name
!Address
!Description
|-
|MIDI_STATUS
|0xDDA0
|Read: Bit[1] = Rx_empty, Bit[2] = Tx_empty
|-
|MIDI_FIFO_DATA_PORT
|0xDDA1
|read and write Data Port
|-
|MIDI_RXD_COUNT_LOW 
|0xDDA2
|Rx FIFO Data Count LOW
|-
|MIDI_RXD_COUNT_HI 
|0xDDA3
|Rx FIFO Data Count Hi - Only the 4 first bit are valid
|-
|MIDI_TXD_COUNT_LOW 
|0xDDA4
|Tx FIFO Data Count LOW
|-
|MIDI_TXD_COUNT_HI 
|0xDDA5
|Tx FIFO Data Count Hi - Only the 4 first bit are valid
|}


=== Steps in order to use MIDI OUT ===
=== Steps in order to use MIDI OUT ===
Line 11: Line 43:
'''MIDI OUT picks data from your program and sends it out to the SAM2695 chip as well as the MIDI Out port to an external device.'''
'''MIDI OUT picks data from your program and sends it out to the SAM2695 chip as well as the MIDI Out port to an external device.'''


Send a MIDI command through 0xDDA1 in rapid sequence.
Send a MIDI command to 0xDDA1 by writing all the bytes of the MIDI command in rapid sequence.
For example, a middle C sent to MIDI channel 0 at moderate speed would be the bytes:<br>
 
Moderately heavy middle C to channel 0: 0x90, 0x40, 0x40<br>
Changing the instrument of channel 0 to a Slap Bass 1: 0xC0, 0x24<br>


<p>
Note On as a moderately heavy middle C to channel 0: 0x90, 0x39, 0x40<br>
Note Off as a softly released middle C to channel 0: 0x80, 0x39, 0x00<br>
Changing the instrument of channel 2 to a Slap Bass 1: 0xC2, 0x24<br>
Shut the 6th channel off: 0xB5, 0x7B, 0x00<br>


=== Steps in order to use MIDI IN ===
=== Steps in order to use MIDI IN ===


to do: revise this with an accurate procedure.<br>
'''MIDI IN refers to an external MIDI controller (ie piano keyboard) that sends MIDI formatted bytes into the Foenix' MIDI in port'''
 
 
0xDDA0 is a control register - full usage is unknown<br>
 
0xDDA1 is the serial data register - unknown how to use it in a MIDI in context<br>


0xDDA2 and 0xDDA3 are the low and high bytes representing the count of buffered midi bytes in the FIFO buffer<br>
First, verify if there are bytes pending in the FIFO buffer by checking if MIDI_STATUS register bit 0 is set to 1 - if so, then create the following loop with steps 2,3,4<br>
Second, read MIDI_RXD_COUNT_LOW as the low byte of a 16-bit value and MIDI_RXD_COUNT_HI as the high byte of the same value to see how many loop iterations must be done<br>
Third, read a byte from MIDI_FIFO_DATA_PORT. Keep in mind that reading a byte from the buffer 'consumes & removes it' and will reduce the FIFO count by one.<br>
Fourth, if you just want to blindly send the bytes to the SAM2695, then write each byte back to MIDI_FIFO_DATA_PORT as they are parsed<br>
Optionally, you may want to react to the bytes, analyze them, modify them before sending them off to MIDI_FIFO_DATA_PORT<br><br>

Latest revision as of 09:44, 11 March 2025

Sam2695 Dream IC is in the F256K2 and F256Jr2 only

The SAM2695 datasheet can be found in this goodies github repo: https://github.com/Mu0n/F256MiscGoodies/blob/main/datasheets/SAM2695.pdf

The MIDI specification from MIDI.org can be found in the organization's website https://midi.org/specs

There are many tutorials and overview of useful MIDI commands, here is one of them: https://www.cs.cmu.edu/~music/cmsip/readings/MIDI%20tutorial%20for%20programmers.html

Here's a reference list of General MIDI instruments by number: https://www.ccarh.org/courses/253/handout/gminstruments/

Register Name Address Description
MIDI_STATUS 0xDDA0 Read: Bit[1] = Rx_empty, Bit[2] = Tx_empty
MIDI_FIFO_DATA_PORT 0xDDA1 read and write Data Port
MIDI_RXD_COUNT_LOW 0xDDA2 Rx FIFO Data Count LOW
MIDI_RXD_COUNT_HI 0xDDA3 Rx FIFO Data Count Hi - Only the 4 first bit are valid
MIDI_TXD_COUNT_LOW 0xDDA4 Tx FIFO Data Count LOW
MIDI_TXD_COUNT_HI 0xDDA5 Tx FIFO Data Count Hi - Only the 4 first bit are valid

Steps in order to use MIDI OUT

MIDI OUT picks data from your program and sends it out to the SAM2695 chip as well as the MIDI Out port to an external device.

Send a MIDI command to 0xDDA1 by writing all the bytes of the MIDI command in rapid sequence.

Note On as a moderately heavy middle C to channel 0: 0x90, 0x39, 0x40
Note Off as a softly released middle C to channel 0: 0x80, 0x39, 0x00
Changing the instrument of channel 2 to a Slap Bass 1: 0xC2, 0x24
Shut the 6th channel off: 0xB5, 0x7B, 0x00

Steps in order to use MIDI IN

MIDI IN refers to an external MIDI controller (ie piano keyboard) that sends MIDI formatted bytes into the Foenix' MIDI in port

First, verify if there are bytes pending in the FIFO buffer by checking if MIDI_STATUS register bit 0 is set to 1 - if so, then create the following loop with steps 2,3,4
Second, read MIDI_RXD_COUNT_LOW as the low byte of a 16-bit value and MIDI_RXD_COUNT_HI as the high byte of the same value to see how many loop iterations must be done
Third, read a byte from MIDI_FIFO_DATA_PORT. Keep in mind that reading a byte from the buffer 'consumes & removes it' and will reduce the FIFO count by one.
Fourth, if you just want to blindly send the bytes to the SAM2695, then write each byte back to MIDI_FIFO_DATA_PORT as they are parsed
Optionally, you may want to react to the bytes, analyze them, modify them before sending them off to MIDI_FIFO_DATA_PORT