Uno r4 minima compilation error

Hello.

When I try do compile this program

#include <Wire.h>

#define DQ0 0x206 //electrov

void setup() {
  pinMode(DQ0, OUTPUT);

}

void loop() {
  digitalWrite(DQ0, HIGH);
  delay(1500);
  digitalWrite(DQ0, LOW);
  delay(1500);
}

I get this error

My platformio.ini file is

[env:uno_r4_minima]
platform = renesas-ra
board = uno_r4_minima
framework = arduino

I already try to delete “.platformio” folder and re instal it, but without sucess.

I need help please

Please file a bug at https://github.com/platformio/platform-renesas-ra/issues instead of here.

Also this one makes no sense, the Arduino functions pinMode(), digitalWrite() etc expect a Arduino pin number, there is absolutely no pin “518” in the entirety of available pins (i.e., 0 to 22)

Ouch, sorry, I didn’t know this link

I made a custom uno R4 pcb, where the P206 of the renesas Uc is an output for me.
So, because arduino doesn’t use this pin like me, I hoped use this pin directly by using the “0x206” adress, like it is described in the bsp_io.h located in the folder .platformio\packages\framework-arduinorenesas-uno\variants\MINIMA\includes\ra\fsp\src\bsp\mcu\all

So I guess my programmation level is too low to understand how to use this specific port without using the uno r4 standard pin…

Thank you for your response

The Arduino pins work by you giving it an index (as I said 0 to 22 are defined in the case of the standard Arduino Uno R4 Minima variant, 26 if you count the SWD connector). This is then translated by the variant’s pin config table into the actual Renesas pin.

Which is also connected to this pinmux data

You can see that translation happening here.

That means that you

  1. can create your own board variant where you extend this list and thus create a new possible Arduino pin, i.e. simply a new entry
  { BSP_IO_PORT_02_PIN_06,    P206   } /* (27) Renesas P2.06*/
  1. Use the Renesas HAL (“FSP”) directly with stuff like
R_IOPORT_PinCfg(NULL, BSP_IO_PORT_02_PIN_06,  IOPORT_CFG_PORT_DIRECTION_OUTPUT);
R_IOPORT_PinWrite(NULL, BSP_IO_PORT_02_PIN_06, BSP_IO_LEVEL_LOW);
delay(1000);
R_IOPORT_PinWrite(NULL, BSP_IO_PORT_02_PIN_06, BSP_IO_LEVEL_HIGH);

Thank you very much @maxgerhardt
The program works fine when I use already define port with the code bellow (my pcb corresponding led blinks)

#define DQ0 BSP_IO_PORT_02_PIN_06

void setup() {
  //pinMode(DQ0, OUTPUT);
  R_IOPORT_PinCfg(NULL, DQ0,  IOPORT_CFG_PORT_DIRECTION_OUTPUT);

}

void loop() {

R_IOPORT_PinWrite(NULL, DQ0, BSP_IO_LEVEL_LOW);
delay(1500);
R_IOPORT_PinWrite(NULL, DQ0, BSP_IO_LEVEL_HIGH);
delay(1500);
}

But strangely, when I use the code below, with pinMode function, the program compile and uploading is ok, but the led doesn’t blink…

#define DQ0 BSP_IO_PORT_02_PIN_06

void setup() {
  pinMode(DQ0, OUTPUT);
  //R_IOPORT_PinCfg(NULL, DQ0,  IOPORT_CFG_PORT_DIRECTION_OUTPUT);

}

void loop() {

R_IOPORT_PinWrite(NULL, DQ0, BSP_IO_LEVEL_LOW);
delay(1500);
R_IOPORT_PinWrite(NULL, DQ0, BSP_IO_LEVEL_HIGH);
delay(1500);
}

I seems that pinMode function doesn’t work properly with BSP_IO_PORT_02_PIN_06 words…

Yes, since per above pinMode() expects an index and uses the translation to map index to BSP_IO_PORT_… You can’t give it an BSP IO PORT directly.

So, where arduino default pin are defined, where can we see for exemple D0 = BSP_IO_PORT_03_PIN_01 ?
Because in the variant.cpp file, the renesas pin are not directly assign to the arduino pin.

Again. Please read the above responses carefully. All the code needed to understand this is there.

The core never does D0 = BSP_IO_PORT_03_PIN_01. It just exposes D0 = 0.

The pinmode functions etc then consult the pin table g_pin_cfg at the index given (e.g. at D0 = 0).

And that then maps to BSP_IO_PORT_03_PIN_01, which is the used value.

Ok, thanks again. I need to look at it closely to understand it.
:slight_smile: