# IIC\_MIDI how to access the RI\_N\_PINs

**URL:** <https://forum.midibox.org/t/iic-midi-how-to-access-the-ri-n-pins/18839>\
**Category:** Testing/Troubleshooting\
**Tags:** iic\_midi, gpio\
**Created:** [January 23, 2015, 2:25pm UTC](https://forum.midibox.org/t/iic-midi-how-to-access-the-ri-n-pins/18839 "2015-01-23T14:25:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nlate](https://forum.midibox.org/letter_avatar_proxy/v4/letter/n/d26b3c/32.png) [@nlate](https://forum.midibox.org/u/nlate)\
**Post date:** [January 23, 2015, 2:25pm UTC](https://forum.midibox.org/t/iic-midi-how-to-access-the-ri-n-pins/18839/1 "2015-01-23T14:25:04Z")

</div>

Dear MIDIBOXers,

During integration of my IIC\_MIDI hardware module I run into an issue of using the RI\_N\_PINs.  
Just some simple questions:  
To which PORT and PINs are this inputs assigned ?

1. On the old **STM32F0x** based PCB
2. On my current **LPC17** based PCB
3. On the new **STM32F4** based PCB

In the mios32\_config.h there only seems to be mentioned the old STM32F0x scheme,

which uses the J5C for RI0..RI3 and J5A for RI4..7.  
If these Port Pins would actually used as Inputs for signalling in case a MIDI Message was received the \_ENABLED flag should be set to:

```
3 = interface enabled, check RI_N pin instead of polling receive status

```

Right?

```
#define MIOS32_IIC_MIDI0_ENABLED 2
#define MIOS32_IIC_MIDI0_RI_N_PORT GPIOC
#define MIOS32_IIC_MIDI0_RI_N_PIN GPIO_Pin_0
....
....
#define MIOS32_IIC_MIDI7_ENABLED 2
#define MIOS32_IIC_MIDI7_RI_N_PORT GPIOA
#define MIOS32_IIC_MIDI7_RI_N_PIN GPIO_Pin_3

```

How has this **mios32\_config.h** file to be modified ?

1. for the **LPC17** core
2. for the **STM32F4** core

What are the Port and Pin Names ?

1. on the **LPC17** core based PCB
2. on the **STM32F4** core based PCB

Thanks in advance for your advice & support and best regards,  
Jo

---

<div class="post-metadata">

**Author:** ![T.K](https://forum.midibox.org/user_avatar/forum.midibox.org/t.k/32/7_2.png) [@T.K](https://forum.midibox.org/u/T.K)\
**Post date:** [January 25, 2015, 8:43pm UTC](https://forum.midibox.org/t/iic-midi-how-to-access-the-ri-n-pins/18839/2 "2015-01-25T20:43:47Z")

</div>

The RI\_N support for IIC\_MIDI is in a bad state - actually I never adapted to LPC17 because the way how the port & pin is specified doesn’t work for a LPC17, and I haven’t adapted for STM32F4 because I knew that this configuration needs to be changed.

&nbsp;

I think that some generic MIOS32\_\* functions are required to configure IO pins, so that the IIC\_MIDI driver could just pass the port “number” and pin number

&nbsp;

&nbsp;

> What are the Port and Pin Names ?

&nbsp;

The intention was to make this free configurable.

It’s a very app specific configuration, because there are no dedicated pins for the RI\_N signals, so that the app developer has to decide which spare pins could be used for that purpose.

&nbsp;

Best Regards, Thorsten.

---

<div class="post-metadata">

**Author:** ![nlate](https://forum.midibox.org/letter_avatar_proxy/v4/letter/n/d26b3c/32.png) [@nlate](https://forum.midibox.org/u/nlate)\
**Post date:** [January 26, 2015, 9:04pm UTC](https://forum.midibox.org/t/iic-midi-how-to-access-the-ri-n-pins/18839/3 "2015-01-26T21:04:17Z")

</div>

Dear Thorsten

Thanks for your reply.

During further investigation related to the RI\_N topic I found the following issue in mios32\common\mios32\_iic\_midi.c:

```
....
#elif defined(MIOS32_FAMILY_LPC17xx)
#if MIOS32_IIC_MIDI0_ENABLED == 3
  MIOS32_SYS_LPC_PINSEL(MIOS32_IIC_MIDI0_RI_N_PORT, MIOS32_IIC_MIDI0_RI_N_PIN, 0);
  MIOS32_SYS_LPC_FIODIR(MIOS32_IIC_MIDI0_RI_N_PORT, MIOS32_IIC_MIDI0_RI_N_PIN, 0); // <-- This function/macro doesnÂ´t excist !!
....
....
#if MIOS32_IIC_MIDI7_ENABLED == 3
  MIOS32_SYS_LPC_PINSEL(MIOS32_IIC_MIDI7_RI_N_PORT, MIOS32_IIC_MIDI7_RI_N_PIN, 0);
  MIOS32_SYS_LPC_FIODIR(MIOS32_IIC_MIDI7_RI_N_PORT, MIOS32_IIC_MIDI7_RI_N_PIN, 0);
.....

```

&nbsp;

also at  
&nbsp;

```
.....
# elif defined(MIOS32_FAMILY_LPC17xx)
    case 0: return MIOS32_SYS_LPC_FIOGET(MIOS32_IIC_MIDI0_RI_N_PORT, MIOS32_IIC_MIDI0_RI_N_PIN) ? 0 : 1; // <-- This function/macro doesnÂ´t excist !!
....
....
# elif defined(MIOS32_FAMILY_LPC17xx)
    case 6: return MIOS32_SYS_LPC_FIOGET(MIOS32_IIC_MIDI6_RI_N_PORT, MIOS32_IIC_MIDI6_RI_N_PIN) ? 0 : 1;
....

```

&nbsp;

I replaced

```
MIOS32_SYS_LPC_FIODIR() with the MIOS32_SYS_LPC_PINDIR() macro

```

&nbsp;

&nbsp;

and replaced

```
MIOS32_SYS_LPC_FIOGET() with the MIOS32_SYS_LPC_PINGET() macro

```

&nbsp;

The app at Mios32\apps\troubleshooting\iic\_midi compiled and linked successfully afterwards!

The related Port (J10 on the LPC17 booard) was also found. It is defined in:  
Mios32\include\mios32\mios32\_iic\_midi.h, where Port J10 D0..7 relates to RI\_N ICC 1..8

I Modified the Mios32\apps\troubleshooting\iic\_midi\mios32\_config.h:

```
....
#define MIOS32_IIC_MIDI0_ENABLED 3

```

&nbsp;

and connected the IIC\_MIDI Module with your firmware and RI PIN connected and i **t behaves correctly as with simple IIC Port polling!**

could you agree that my assumptions are correct?

Best regards,  
Jo  
&nbsp;

---

<div class="post-metadata">

**Author:** ![T.K](https://forum.midibox.org/user_avatar/forum.midibox.org/t.k/32/7_2.png) [@T.K](https://forum.midibox.org/u/T.K)\
**Post date:** [January 26, 2015, 9:37pm UTC](https://forum.midibox.org/t/iic-midi-how-to-access-the-ri-n-pins/18839/4 "2015-01-26T21:37:01Z")

</div>

Yes, right

&nbsp;

I corrected this, and also enabled the same pin configuration for STM31F4 like for STM31F1

&nbsp;

But as mentioned before: actually I would like to overwork the configuration… sooner or later… to make it more generic.

&nbsp;

Best Regards, Thorsten.
