MIOS DIN/DOUT Pin Numbers

Sometimes the pin numbers of special DINs or DOUTs can be specified in the main.asm or setup_*.asm file of a MIOS application.

Examples:

#define DEFAULT_MIDI_RX_LED 0x40        ; DOUT SR#9, pin D0
#define DEFAULT_MIDI_TX_LED 0x41        ; DOUT SR#9, pin D1

or

#define DEFAULT_DIN_MENU_EXEC         7       ; menu exec button assigned to DIN pin #7
#define DEFAULT_DIN_MENU_SNAPSHOT     6       ; menu snapshot button assigned to DIN pin #4
#define DEFAULT_DIN_MENU_RIGHT        5       ; NOT USED - overlayed by datawheel
#define DEFAULT_DIN_MENU_LEFT         4       ; NOT USED - overlayed by datawheel

or

       ;;        SR  Pin  Mode
        ENC_ENTRY  5,  0,  MIOS_ENC_MODE_NON_DETENTED   ; V-Pot 1
        ENC_ENTRY  5,  2,  MIOS_ENC_MODE_NON_DETENTED   ; V-Pot 2
        ENC_ENTRY  5,  4,  MIOS_ENC_MODE_NON_DETENTED   ; V-Pot 3
        ENC_ENTRY  5,  6,  MIOS_ENC_MODE_NON_DETENTED   ; V-Pot 4

The following table should give you a quick overview over the numbers. Please bear in mind that we are sometimes counting from 0, and sometimes from 1.

Means: sometimes the first pin or shiftregister has number 0, sometimes it has number 1 - thats always an issue, because programmer mostly prefer to count from 0, users want to count from 1 - it's a bit of a mess! Forgive me! ;-)

In the meantime I've tried to make the setup more consistent. Shiftregisters are always counted from 1, and pins are always counted from 0


Important Note: for DOUT shift registers, software pin-numbers will be reflected in reverse direction on hardware level:

pin-number 0 (software level) is D7 of the first shift register (hardware level), not D0!
pin-number 15 (software level) is D0 of the second shift register(hardware level), not D7!

The first shift register is for both DIN and DOUT the one that is closest to the core on hardware level.

In the datasheets of the shift-register IC's, D0 is often labled A / QA, D7 is labled H / QH.
In TK's layouts the labels for IC-pins are I0 - I7, O0 - 07, which corresponds to A/QA - H/QH.

DIN chain hardware-level: CORE ← R1::qH ← R1::H ← R1 ← R1::G ….. R2::qH ← R2::H etc.
The first bit read is DIN1::I7, this goes to the MSB on software level. MSB represents the higher pin value, so you have the same order in hard- as in software.

DOUT chain hardware-level: CORE → R1::SER → R1::A → R1::B → R1::C ….. R2::SER → R2::A etc.
first bit pushed out is LSB of the last SR(software level), this goes to Rlast::H. Last bit pushed out is MSB of first SR (software level), this goes to R1:A. On software level, MSB represents the higher pin value, so A will represent alway the higher pin value on hw-level for DOUT chains.

If you want to read more about this, refer this forum discussion:
http://www.midibox.org/forum/index.php/topic,12379.0.html

See also the following table to get a clearer picture. The shift registers have the same order on hardware than on software level.

MIOS_DOUT_SRSet / MIOS_DOUT_SRGet / MIOS_DIN_SRSet / MIOS_DIN_SRGet: LSB always reflects the lowest pin number, MSB the highest pin number.




Ok, here the table:

Shift Register SR number Pin Number (sw) Pin Hex number (sw) Pin Name (DIN PCB / SR IC) Pin Name (DOUT PCB / SR IC)
first100x00D0 / QAD7 / H
first110x00D1 / QBD6 / G
first120x00D2 / QCD5 / F
first130x00D3 / QDD4 / E
first140x00D4 / QED3 / D
first150x00D5 / QFD2 / C
first160x00D6 / QGD1 / B
first170x00D7 / QHD0 / A
second280x0 8D0 / QAD7 / H
second290x0 9D1 / QBD6 / G
second2100x0aD2 / QCD5 / F
second2110x0bD3 / QDD4 / E
second2120x0cD4 / QED3 / D
second2130x0dD5 / QFD2 / C
second2140x0eD6 / QGD1 / B
second2150x0fD7 / QHD0 / A
third3160x10D0 / QAD7 / H
third3170x11D1 / QBD6 / G
third3180x12D2 / QCD5 / F
third3190x13D3 / QDD4 / E
third3200x14D4 / QED3 / D
third3210x15D5 / QFD2 / C
third3220x16D6 / QGD1 / B
third3230x17D7 / QHD0 / A
fourth4240x18D0 / QAD7 / H
fourth4250x19D1 / QBD6 / G
fourth4260x1aD2 / QCD5 / F
fourth4270x1bD3 / QDD4 / E
fourth4280x1cD4 / QED3 / D
fourth4290x1dD5 / QFD2 / C
fourth4300x1eD6 / QGD1 / B
fourth4310x1fD7 / QHD0 / A
fifth5320x20D0 / QAD7 / H
fifth5330x21D1 / QBD6 / G
fifth5340x22D2 / QCD5 / F
fifth5350x23D3 / QDD4 / E
fifth5360x24D4 / QED3 / D
fifth5370x25D5 / QFD2 / C
fifth5380x26D6 / QGD1 / B
fifth5390x27D7 / QHD0 / A
sixth6400x2 8D0 / QAD7 / H
sixth6410x2 9D1 / QBD6 / G
sixth6420x2aD2 / QCD5 / F
sixth6430x2bD3 / QDD4 / E
sixth6440x2cD4 / QED3 / D
sixth6450x2dD5 / QFD2 / C
sixth6460x2eD6 / QGD1 / B
sixth6470x2fD7 / QHD0 / A
seventh7480x30D0 / QAD7 / H
seventh7490x31D1 / QBD6 / G
seventh7500x32D2 / QCD5 / F
seventh7510x33D3 / QDD4 / E
seventh7520x34D4 / QED3 / D
seventh7530x35D5 / QFD2 / C
seventh7540x36D6 / QGD1 / B
seventh7550x37D7 / QHD0 / A
eighth8560x3 8D0 / QAD7 / H
eighth8570x3 9D1 / QBD6 / G
eighth8580x3aD2 / QCD5 / F
eighth8590x3bD3 / QDD4 / E
eighth8600x3cD4 / QED3 / D
eighth8610x3dD5 / QFD2 / C
eighth8620x3eD6 / QGD1 / B
eighth8630x3fD7 / QHD0 / A
ninth9640x40D0 / QAD7 / H
ninth9650x41D1 / QBD6 / G
ninth9660x42D2 / QCD5 / F
ninth9670x43D3 / QDD4 / E
ninth9680x44D4 / QED3 / D
ninth9690x45D5 / QFD2 / C
ninth9700x46D6 / QGD1 / B
ninth9710x47D7 / QHD0 / A
tenth10720x4 8D0 / QAD7 / H
tenth10730x4 9D1 / QBD6 / G
tenth10740x4aD2 / QCD5 / F
tenth10750x4bD3 / QDD4 / E
tenth10760x4cD4 / QED3 / D
tenth10770x4dD5 / QFD2 / C
tenth10780x4eD6 / QGD1 / B
tenth10790x4fD7 / QHD0 / A
eleventh11800x50D0 / QAD7 / H
eleventh11810x51D1 / QBD6 / G
eleventh11820x52D2 / QCD5 / F
eleventh11830x53D3 / QDD4 / E
eleventh11840x54D4 / QED3 / D
eleventh11850x55D5 / QFD2 / C
eleventh11860x56D6 / QGD1 / B
eleventh11870x57D7 / QHD0 / A
twelfth12880x5 8D0 / QAD7 / H
twelfth12890x5 9D1 / QBD6 / G
twelfth12900x5aD2 / QCD5 / F
twelfth12910x5bD3 / QDD4 / E
twelfth12920x5cD4 / QED3 / D
twelfth12930x5dD5 / QFD2 / C
twelfth12940x5eD6 / QGD1 / B
twelfth12950x5fD7 / QHD0 / A
thirteenth13960x60D0 / QAD7 / H
thirteenth13970x61D1 / QBD6 / G
thirteenth13980x62D2 / QCD5 / F
thirteenth13990x63D3 / QDD4 / E
thirteenth131000x64D4 / QED3 / D
thirteenth131010x65D5 / QFD2 / C
thirteenth131020x66D6 / QGD1 / B
thirteenth131030x67D7 / QHD0 / A
fourteenth141040x6 8D0 / QAD7 / H
fourteenth141050x6 9D1 / QBD6 / G
fourteenth141060x6aD2 / QCD5 / F
fourteenth141070x6bD3 / QDD4 / E
fourteenth141080x6cD4 / QED3 / D
fourteenth141090x6dD5 / QFD2 / C
fourteenth141100x6eD6 / QGD1 / B
fourteenth141110x6fD7 / QHD0 / A
fifteenth151120x70D0 / QAD7 / H
fifteenth151130x71D1 / QBD6 / G
fifteenth151140x72D2 / QCD5 / F
fifteenth151150x73D3 / QDD4 / E
fifteenth151160x74D4 / QED3 / D
fifteenth151170x75D5 / QFD2 / C
fifteenth151180x76D6 / QGD1 / B
fifteenth151190x77D7 / QHD0 / A
sixteenth161200x7 8D0 / QAD7 / H
sixteenth161210x7 9D1 / QBD6 / G
sixteenth161220x7aD2 / QCD5 / F
sixteenth161230x7bD3 / QDD4 / E
sixteenth161240x7cD4 / QED3 / D
sixteenth161250x7dD5 / QFD2 / C
sixteenth161260x7eD6 / QGD1 / B
sixteenth161270x7fD7 / QHD0 / A