Arduino HAT Carrier RPI to Arduino IDE Pin Mapping

I have collected all these links into a Bookmarks folder. 😄 Thank you for this information! Maybe I can dissect all this information and get us all much needed reference. 😄
29 Replies
Maverick
Maverick•2y ago
The SAI pins on the rpi header are on the J2 HD connector and can be used as 78, 79, 80 and 81 in Arduino code -> https://docs.arduino.cc/resources/pinouts/ABX00074-full-pinout.pdf This should be the full pinout for the rpi header which you can use in your Arduino code:
PWM 0 = 0
PWM 1 = 1
PWM 2 = 2
PWM 3 = 3
PWM 4 = 4
PWM 5 = 5
PWM 6 = 6
I2C0 SDA = 11
I2C0 SCL = 12
I2C2 SDA = 39
I2C2 SCL = 40
SPI1 CIPO = 45
SPI1 COPI = 46
SPI1 SCK = 47
SPI1 CE = 48
TX3 = 53
RX3 = 54
I2S CK = 63
I2S WS = 64
I2S SDI = 65
I2S SDO = 66
SAI DO = 80
SAI FS = 79
SAI CK = 78
TX1 = 92 (Connected to ESP32 on board.)
RX1 = 93 (Connected to ESP32 on board.)
PWM 0 = 0
PWM 1 = 1
PWM 2 = 2
PWM 3 = 3
PWM 4 = 4
PWM 5 = 5
PWM 6 = 6
I2C0 SDA = 11
I2C0 SCL = 12
I2C2 SDA = 39
I2C2 SCL = 40
SPI1 CIPO = 45
SPI1 COPI = 46
SPI1 SCK = 47
SPI1 CE = 48
TX3 = 53
RX3 = 54
I2S CK = 63
I2S WS = 64
I2S SDI = 65
I2S SDO = 66
SAI DO = 80
SAI FS = 79
SAI CK = 78
TX1 = 92 (Connected to ESP32 on board.)
RX1 = 93 (Connected to ESP32 on board.)
Hybrid🤖RobotiX [N7PKT]
Thank you! I will add these to my file and do some testing to see if I can access them.
Hybrid🤖RobotiX [N7PKT]
Some of these pins are not going to map correctly to the connector.
No description
Maverick
Maverick•2y ago
Which pins? It is upside down compared to the Portenta pinout. Could be confusing.
Hybrid🤖RobotiX [N7PKT]
I know. I think I understand how it works now. Are those pin numbers from the Portenta MCU?
Maverick
Maverick•2y ago
Hybrid🤖RobotiX [N7PKT]
Ah, OK. That is important information. Now, I can properly label that column. 😉 I think a spread sheet is in order... 😉 We have a total of 25 pin now. Are these all guaranteed to be routed to the RPI Connector??
Maverick
Maverick•2y ago
Yeah, the HD connectors plug into the hat carrier which connects those pins to the raspberry pi header. You can actually see them all here on the HD connector pinouts (J1 and J2): https://docs.arduino.cc/resources/pinouts/ABX00074-full-pinout.pdf
Hybrid🤖RobotiX [N7PKT]
Ah, OK. That does not tell me anything about the RPI Connector though. I understand the naming convention now though, which is good. 🙂 It only covers the MKR compatible pins on the board. You might want to change the title of this thread to something like "Arduino HAT Carrier RPI to Arduino IDE Pin Mapping"
Maverick
Maverick•2y ago
I created an image with the numbers. @HybridRobotix
No description
Hybrid🤖RobotiX [N7PKT]
Very nice! 😄 I received an email from Arduino with the following: I need to experiment and see if this really gives us what we need. https://docs.arduino.cc/resources/pinouts/ASX00049-full-pinout.pdf And this: https://docs.arduino.cc/hardware/portenta-hat-carrier/#features
Maverick
Maverick•2y ago
Those documents in addition to this one (https://docs.arduino.cc/resources/pinouts/ABX00074-full-pinout.pdf) are how I got the numbers for the image. They also align with the array indices here: https://github.com/arduino/ArduinoCore-renesas/blob/main/variants/PORTENTA_C33/variant.cpp#L40, so they should work in your code with pinMode, digitalWrite, etc.
Hybrid🤖RobotiX [N7PKT]
I used the BSP* designations in my sketch and it compiled! Now, I have to see if I can access the hardware pins. 😄 However, I think using these designations in sketches is highly undesirable and unfriendly, so I think we need a friendlier pin mapping for Arduino. I still need to do some thinking on this.
#define SWITCH_0_PIN D6
#define SWITCH_1_PIN BSP_IO_PORT_04_PIN_07 // D11 Raspberry Pi Connector
#define SWITCH_2_PIN BSP_IO_PORT_04_PIN_08 // D12 Raspberry Pi Connector

uint8_t SWITCHES[3] = { SWITCH_0_PIN, SWITCH_1_PIN, SWITCH_2_PIN };
#define NUMBER_OF_SWITCHES (sizeof(SWITCHES) / sizeof(uint8_t))
String SWITCH_NAMES[NUMBER_OF_SWITCHES] = { "One", "Two", "Three" };
bool switch_readings[NUMBER_OF_SWITCHES] = { false, false, false };
#define SWITCH_0_PIN D6
#define SWITCH_1_PIN BSP_IO_PORT_04_PIN_07 // D11 Raspberry Pi Connector
#define SWITCH_2_PIN BSP_IO_PORT_04_PIN_08 // D12 Raspberry Pi Connector

uint8_t SWITCHES[3] = { SWITCH_0_PIN, SWITCH_1_PIN, SWITCH_2_PIN };
#define NUMBER_OF_SWITCHES (sizeof(SWITCHES) / sizeof(uint8_t))
String SWITCH_NAMES[NUMBER_OF_SWITCHES] = { "One", "Two", "Three" };
bool switch_readings[NUMBER_OF_SWITCHES] = { false, false, false };
Maverick
Maverick•2y ago
You can just use the numbers from the image I created (https://discord.com/channels/420594746990526466/1206334029931094047/1206350354069856346).
#define SWITCH_1_PIN 66 // I2S SDO Raspberry Pi Connector
#define SWITCH_2_PIN 65 // I2S SDI Raspberry Pi Connector
#define SWITCH_1_PIN 66 // I2S SDO Raspberry Pi Connector
#define SWITCH_2_PIN 65 // I2S SDI Raspberry Pi Connector
Maverick
Maverick•2y ago
No description
Hybrid🤖RobotiX [N7PKT]
I need to do this my way. 😉 I am almost done making a sample header file with MKR pins so you can see what I have in mind. I will get that off to you in an hour or so. 😉
Hybrid🤖RobotiX [N7PKT]
I need more I/O than what is available on the MKR compatible pins, so I need to access Raspberry Pi Compatible pins on the 40-pin connector. I am also going to need this when I get the Raspberry Pi robot controller I am going to use for this robot. https://www.amazon.com/gp/product/B0BX539VH1/ref=ox_sc_saved_image_3?smid=A1N1A77RUX51FT&psc=1
/*
Arduino HAT Carrier to Arduino IDE Pin Translations
*/

/*
MKR Pins
*/
#define D0 BSP_IO_PORT_01_PIN_05 // P105
#define D1 BSP_IO_PORT_01_PIN_06 // P106
#define D3 BSP_IO_PORT_01_PIN_11 // P111
#define D4 BSP_IO_PORT_03_PIN_03 // P303
#define D5 BSP_IO_PORT_04_PIN_01 // P401
#define D6 BSP_IO_PORT_02_PIN_10 // P210

#define D7 BSP_IO_PORT_06_PIN_01 // P601
#define CS0 D7

#define D8 BSP_IO_PORT_04_PIN_02 // P402
#define MOSI0 D8

#define D9 BSP_IO_PORT_09_PIN_00 // P900
#define SCK0 D9

#define D10 BSP_IO_PORT_03_PIN_15 // P204
#define MOSI0 D10

#define D11 BSP_IO_PORT_04_PIN_07 // P407 *** NOTE: This is I2C SDA on the ESLOV connector
#define SDA0 D11

#define D12 BSP_IO_PORT_04_PIN_08 // P408 *** NOTE: This is I2C SCL on the ESLOV connector
#define SCK0 D12

#define D13 BSP_IO_PORT_01_PIN_10 // P110
#define RX0 RX0

#define D14 BSP_IO_PORT_06_PIN_02 // P602
#define D14 TX0

// Analog pins
#define A0 BSP_IO_PORT_00_PIN_06 // P006
#define D15 A0

#define A1 BSP_IO_PORT_00_PIN_05 // P005
#define D16 A1

#define A2 BSP_IO_PORT_00_PIN_04 // P004

#define A3 BSP_IO_PORT_00_PIN_02 // P002

#define A4 BSP_IO_PORT_00_PIN_01 // P001

#define A5 BSP_IO_PORT_00_PIN_15 // P015
#define D20 A5
#define DAC1 A5

#define A6 BSP_IO_PORT_00_PIN_14 // P014
#define D21 A6
#define DAC0 A6

#define A7 BSP_IO_PORT_00_PIN_00 // P000
#define A7 D22
/*
Arduino HAT Carrier to Arduino IDE Pin Translations
*/

/*
MKR Pins
*/
#define D0 BSP_IO_PORT_01_PIN_05 // P105
#define D1 BSP_IO_PORT_01_PIN_06 // P106
#define D3 BSP_IO_PORT_01_PIN_11 // P111
#define D4 BSP_IO_PORT_03_PIN_03 // P303
#define D5 BSP_IO_PORT_04_PIN_01 // P401
#define D6 BSP_IO_PORT_02_PIN_10 // P210

#define D7 BSP_IO_PORT_06_PIN_01 // P601
#define CS0 D7

#define D8 BSP_IO_PORT_04_PIN_02 // P402
#define MOSI0 D8

#define D9 BSP_IO_PORT_09_PIN_00 // P900
#define SCK0 D9

#define D10 BSP_IO_PORT_03_PIN_15 // P204
#define MOSI0 D10

#define D11 BSP_IO_PORT_04_PIN_07 // P407 *** NOTE: This is I2C SDA on the ESLOV connector
#define SDA0 D11

#define D12 BSP_IO_PORT_04_PIN_08 // P408 *** NOTE: This is I2C SCL on the ESLOV connector
#define SCK0 D12

#define D13 BSP_IO_PORT_01_PIN_10 // P110
#define RX0 RX0

#define D14 BSP_IO_PORT_06_PIN_02 // P602
#define D14 TX0

// Analog pins
#define A0 BSP_IO_PORT_00_PIN_06 // P006
#define D15 A0

#define A1 BSP_IO_PORT_00_PIN_05 // P005
#define D16 A1

#define A2 BSP_IO_PORT_00_PIN_04 // P004

#define A3 BSP_IO_PORT_00_PIN_02 // P002

#define A4 BSP_IO_PORT_00_PIN_01 // P001

#define A5 BSP_IO_PORT_00_PIN_15 // P015
#define D20 A5
#define DAC1 A5

#define A6 BSP_IO_PORT_00_PIN_14 // P014
#define D21 A6
#define DAC0 A6

#define A7 BSP_IO_PORT_00_PIN_00 // P000
#define A7 D22
This is just a sample of what I am working on. I still need to add the rest of the pins on the Raspberry Pi header.
Yahboom Multifunctional Development Board for Raspberry Pi Jetson N...
Yahboom Multifunctional Development Board for Raspberry Pi Jetson Nano Building ROS1 ROS2 Robot Expansion Board with 9-axis IMU Sensor STM32F103C8T6 Core (ROS Expansion Board)
Maverick
Maverick•2y ago
I am confused. I think there is some communication failure here. I labeled every pin on the 40 pin header in the image I made. BSP_IO_PORT_01_PIN_05 is already defined as D0 in the renesas arduino core. You don't need to create these defines. The arduino core takes care of everything with the pin mux configuration here: https://github.com/arduino/ArduinoCore-renesas/blob/main/variants/PORTENTA_C33/variant.cpp#L40 All you need are the numbers in the image I made to use the pins on the 40 pin header. You can use the numbers directly. For example this will set the I2S SDI pin on the 40 pin header to high logic level:
pinMode(65, OUTPUT);
digitalWrite(65, HIGH);
pinMode(65, OUTPUT);
digitalWrite(65, HIGH);
Hybrid🤖RobotiX [N7PKT]
Users should be able to use familiar pin names for the pins they want to use. This also serves as part of the documentation for a sketch. Users should not have to look up what "pin 65" is. This lets users and readers know immediately that D65 is being used as a digital I/O. Maybe somebody wants to use a UART on the Rasberry Pi connector of the Arduino HAT Carrier, they would not be able to make their pin selections easily. As it is now, I can not tell which pins are associated with the Arduino HAT Carrier except those on the MKR pins. I need to know exactly which pins are associated with pins on the Raspberry Pi connector, which go from 1 to 40 and also have pneumonic names that should be usable. The pin designations might be something like "HAT_<RPi neumonic name such as GPIO12_32>." Proper Raspberry Pi pin naming must be used.
Maverick
Maverick•2y ago
I see, so something like this?
#define HAT_PCM_DOUT 65
#define HAT_I2S_SDO 65
#define HAT_PCM_DOUT 65
#define HAT_I2S_SDO 65
That should cover both rpi pinouts and the hat carrier pinout. Should make things easier when you've got it all done. I will leave you to it. 😄
Hybrid🤖RobotiX [N7PKT]
Yes, this is pretty much what I have been thinking about. I want to keep the pin names as short as possible and still keep all the needed information. 😉 I still need to know which pins are on the HAT connector and which Raspberry Pi pins they map to. 😉 I will continue to work on this.
Maverick
Maverick•2y ago
If you flip the RPI pinout image here upside down and compare to the hat carrier image with the numbers, that should give you everything you need. https://fossbytes.com/wp-content/uploads/2021/04/gpio-pins-raspberry-pi-4-e1617866771594.png For example: I2S SDI is GPIO 20 (PCM_DIN) and that is pin 65 on the Portenta C33. TX1 is GPIO 12 (PWM 0) which is pin 92 on the Portenta C33. @HybridRobotix
No description
Hybrid🤖RobotiX [N7PKT]
OK, let me see. Is the pin number on the Portenta the same as the D<number> pins? If this is true then I have everything I need to finish this very quickly. 😉 More tomorrow because I have all day to work on this uninterrupted. 😄 😄 I am exhausted and must have sleep now.
Maverick
Maverick•2y ago
Yes, the same as the D numbers in the Arduino core and these numbers here. https://docs.arduino.cc/resources/pinouts/ABX00074-full-pinout.pdf
No description
Hybrid🤖RobotiX [N7PKT]
There is still no association with the pins on the Arduino HAT Carrier. I am trying to figure out how to get this information most easily but it looks like I will need a schematic to trace the lines. I will see if I can get this information from the Arduino people.
Maverick
Maverick•2y ago
These are the pins on the Arduino HAT Carrier.
No description
Maverick
Maverick•2y ago
Here are the pin numbers for the 16 pin header as well.
No description
Hybrid🤖RobotiX [N7PKT]
Oh, um, yes, I see that now. I apologize for my denseness. 😉 😄 My brain has been on vacation and does not want to come back. 😉 😄
Maverick
Maverick•2y ago
No worries. It happens. 😂

Did you find this page helpful?