Where is PCLK pin defined?

I am using an Arduino Giga R1 board to communicate with a camera connected onto the 20-pin J6 camera connector. I would like to find a header file to include in my sketch that would give me the symbolic names for the pins on the J6 connector. Where would I find such a file? For example, I would want to know in my source code what the symbolic name is for the PCLK pin (also known as PA6 or D56 in the Giga R1 data sheet).

I don't know if this is what you need.


https://docs.arduino.cc/tutorials/giga-r1-wifi/giga-camera/

No, this gives me the names, like PA6 or D56, but they are undefined variables if I just try to use them in the code. I need to #include some header that would have these defined. What header can I use?

Hi @staninmilford.

An arbitrary integer is assigned to each Arduino pins. These pin numbers are the primary identifiers for the pins. There is an unfortunate convention of prefixing the number with a "D" to indicate a digital pin or an "A" to indicate an ADC pin when referring to Arduino pins (apparently the people who established the convention didn't have the foresight to consider that a given pin might have multiple functionalities, even though that was the case even with the AVR microcontrollers in use at the time, and that arbitrarily placing them into distinct "digital" and "analog" categories wasn't a great idea). So just strip off that "D" and use the integer number 56 in any function that takes an Arduino pin number parameter.

If you do like the "D", macros are also defined for each of these names, so you can use D56 instead of 56 if you prefer. These macros are defined in the header file pins_arduino.h. That header file is #included from Arduino.h, for which an #include directive is automatically added to the .ino sketch files. So you don't actually need to think about pins_arduino.h in .ino files, but if you are working with .cpp, .h, .c, etc. files then you might want it since the #include <Arduino.h> is only injected in to the .ino files. I think most people just add the #include for Arduino.h in this case rather than pins_arduino.h specifically since you are probably going to need some of the objects that are declared by Arduino.h (or transitively through it) in any code that uses Arduino pin numbers.

Thanks.

You are welcome. I'm glad if I was able to be of assistance.

Regards,
Per

You can always roll your own :

.ino

#include "myPinNames.h"

int I2Cclock = SCL;
int I2Cdata = SDA;
int pClock = PCLK;

void setup() {
  Serial.begin(115200);
  Serial.println();
  Serial.println(I2Cclock);
  Serial.println(I2Cdata);
  Serial.println(pClock);
}

void loop() {
  // put your main code here, to run repeatedly:

}

.h

#define SDA 23
#define SCL 24
#define PCLK 41

But that illustrates the problem. The symbol PCLK does not appear in the Arduino Giga R1 header file pins_arduino.h. This brings us back to my original question: where is PCLK defined?

Anyhow, I got around the problem by using symbol D56 instead of PCLK.

I found the file variant.cpp under ...hardware/mbed_giga/4.1.3/variants/GIGA/ and it gives almost every pin definition, but not PCLK.

AnalogPinDescription g_AAnalogPinDescription[] = {
  { PC_4,         NULL },    // A0   ADC1_INP4
  { PC_5,         NULL },    // A1   ADC1_INP8
  { PB_0,         NULL },    // A2   ADC1_INP9
  { PB_1,         NULL },    // A3   ADC1_INP5
  { PC_3,         NULL },    // A4   ADC1_INP13
  { PC_2,         NULL },    // A5   ADC1_INP12
  { PC_0,         NULL },    // A6   ADC1_INP10
  { PA_0,         NULL },    // A7   ADC1_INP16
  { PA_4,         NULL },    // A12  DAC1_OUT1
  { PA_5,         NULL },    // A13  DAC1_OUT2
};

AnalogPinDescription g_pureAAnalogPinDescription[] = {
  { PC_2C,        NULL },    // A8   ADC3_INP0
  { PC_3C,        NULL },    // A9   ADC3_INP1
  { PA_1C,        NULL },    // A10  ADC2_INP1
  { PA_0C,        NULL },    // A11  ADC2_INP0
};

AnalogPinDescription g_AAnalogOutPinDescription[] = {
  { PA_4,         NULL },    // A12  DAC1_OUT1
  { PA_5,         NULL },    // A13  DAC1_OUT2
};

PinDescription g_APinDescription[] = {
  // D0 - D21
  { PB_7,         NULL, NULL, NULL },    // D0  RX
  { PA_9,         NULL, NULL, NULL },    // D1  TX
  { PA_3,         NULL, NULL, NULL },    // D2
  { PA_2,         NULL, NULL, NULL },    // D3
  { PJ_8,         NULL, NULL, NULL },    // D4
  { PA_7,         NULL, NULL, NULL },    // D5
  { PD_13,        NULL, NULL, NULL },    // D6
  { PB_4,         NULL, NULL, NULL },    // D7
  { PB_8,         NULL, NULL, NULL },    // D8
  { PB_9,         NULL, NULL, NULL },    // D9
  { PK_1,         NULL, NULL, NULL },    // D10
  { PJ_10,        NULL, NULL, NULL },    // D11
  { PJ_11,        NULL, NULL, NULL },    // D12
  { PH_6,         NULL, NULL, NULL },    // D13
  { PG_14,        NULL, NULL, NULL },    // D14  TX3
  { PC_7,         NULL, NULL, NULL },    // D15  RX3
  { PH_13,        NULL, NULL, NULL },    // D16  TX2
  { PI_9,         NULL, NULL, NULL },    // D17  RX2
  { PD_5,         NULL, NULL, NULL },    // D18  TX1
  { PD_6,         NULL, NULL, NULL },    // D19  RX1
  { PB_11,        NULL, NULL, NULL },    // D20  SDA
  { PH_4,         NULL, NULL, NULL },    // D21  SCL

  // D22 - D53
  { PJ_12,        NULL, NULL, NULL },    // D22
  { PG_13,        NULL, NULL, NULL },    // D23
  { PG_12,        NULL, NULL, NULL },    // D24
  { PJ_0,         NULL, NULL, NULL },    // D25
  { PJ_14,        NULL, NULL, NULL },    // D26
  { PJ_1,         NULL, NULL, NULL },    // D27
  { PJ_15,        NULL, NULL, NULL },    // D28
  { PJ_2,         NULL, NULL, NULL },    // D29
  { PK_3,         NULL, NULL, NULL },    // D30
  { PJ_3,         NULL, NULL, NULL },    // D31
  { PK_4,         NULL, NULL, NULL },    // D32
  { PJ_4,         NULL, NULL, NULL },    // D33
  { PK_5,         NULL, NULL, NULL },    // D34
  { PJ_5,         NULL, NULL, NULL },    // D35
  { PK_6,         NULL, NULL, NULL },    // D36
  { PJ_6,         NULL, NULL, NULL },    // D37
  { PJ_7,         NULL, NULL, NULL },    // D38
  { PI_14,        NULL, NULL, NULL },    // D39
  { PE_6,         NULL, NULL, NULL },    // D40
  { PK_7,         NULL, NULL, NULL },    // D41
  { PI_15,        NULL, NULL, NULL },    // D42
  { PI_10,        NULL, NULL, NULL },    // D43
  { PG_10,        NULL, NULL, NULL },    // D44
  { PI_13,        NULL, NULL, NULL },    // D45
  { PH_15,        NULL, NULL, NULL },    // D46
  { PB_2,         NULL, NULL, NULL },    // D47
  { PK_0,         NULL, NULL, NULL },    // D48
  { PE_4,         NULL, NULL, NULL },    // D49
  { PI_11,        NULL, NULL, NULL },    // D50
  { PE_5,         NULL, NULL, NULL },    // D51
  { PK_2,         NULL, NULL, NULL },    // D52
  { PG_7,         NULL, NULL, NULL },    // D53

  // D54 - D67
  { PI_5,         NULL, NULL, NULL },    // D54
  { PH_8,         NULL, NULL, NULL },    // D55
  { PA_6,         NULL, NULL, NULL },    // D56
  { PJ_9,         NULL, NULL, NULL },    // D57
  { PI_7,         NULL, NULL, NULL },    // D58
  { PI_6,         NULL, NULL, NULL },    // D59
  { PI_4,         NULL, NULL, NULL },    // D60
  { PH_14,        NULL, NULL, NULL },    // D61
  { PG_11,        NULL, NULL, NULL },    // D62
  { PH_11,        NULL, NULL, NULL },    // D63
  { PH_10,        NULL, NULL, NULL },    // D64
  { PH_9,         NULL, NULL, NULL },    // D65
  { PA_1,         NULL, NULL, NULL },    // D66
  { PD_4,         NULL, NULL, NULL },    // D67

  // D68 - D74
  { PC_6,         NULL, NULL, NULL },    // D68
  { PI_0,         NULL, NULL, NULL },    // D69
  { PI_1,         NULL, NULL, NULL },    // D70
  { PI_2,         NULL, NULL, NULL },    // D71
  { PI_3,         NULL, NULL, NULL },    // D72
  { PC_1,         NULL, NULL, NULL },    // D73
  { PB_12,        NULL, NULL, NULL },    // D74
  { PD_3,         NULL, NULL, NULL },    // D75

  // A0 - A9
  { PC_4,         NULL, NULL, NULL },    // A0 (D76)
  { PC_5,         NULL, NULL, NULL },    // A1 (D77)
  { PB_0,         NULL, NULL, NULL },    // A2 (D78)
  { PB_1,         NULL, NULL, NULL },    // A3 (D79)
  { PC_3,         NULL, NULL, NULL },    // A4 (D80)
  { PC_2,         NULL, NULL, NULL },    // A5 (D81)
  { PC_0,         NULL, NULL, NULL },    // A6 (D82)
  { PA_0,         NULL, NULL, NULL },    // A7 (D83)
  { PA_4,         NULL, NULL, NULL },    // A12  DAC0 (D84)
  { PA_5,         NULL, NULL, NULL },    // A13  DAC1 (D85)

  // LEDS
  { PI_12,        NULL, NULL, NULL },    // D86  LEDR
  { PJ_13,        NULL, NULL, NULL },    // D87  LEDG
  { PE_3,         NULL, NULL, NULL },    // D88  LEDB

  // SPI1
  { PG_9,         NULL, NULL, NULL },    // D89  MISO
  { PD_7,         NULL, NULL, NULL },    // D90  MOSI
  { PB_3,         NULL, NULL, NULL },    // D91  SCK

  // USB HOST ENABLE
  { PA_15,        NULL, NULL, NULL },    // D92  USB HOST ENABLE

  // CAN
  { PB_5,         NULL, NULL, NULL },    // D93  CAN RX
  { PB_13,        NULL, NULL, NULL },    // D94  CAN TX

  // WIFI CONTROL
  { PI_8,         NULL, NULL, NULL },    // D95  WIFI HOST WAKE
  { PB_10,        NULL, NULL, NULL },    // D96  WIFI ON

  // BLE CONTROL
  { PH_7,         NULL, NULL, NULL },    // D97  BLE DEVICE WAKE
  { PG_3,         NULL, NULL, NULL },    // D98  BLE HOST WAKE
  { PA_10,        NULL, NULL, NULL },    // D99  BLE ON

  // BOOT
  { PC_13,        NULL, NULL, NULL },    // D100 BOOT0

  // I2C1
  { PB_6_ALT0,    NULL, NULL, NULL },    // D101  SCL1
  { PH_12,        NULL, NULL, NULL },    // D102  SDA1
};

This is actually where the pin numbers are defined. The Arduino pin number is the index of the array. You can see that the 56th element in the array is PA_6.

Why is that a problem. Many different names might be used to describe an I/O pin to a human, but there is no requirement that we must be able to use any of those in our code.

As already explained, you are welcome (and encouraged) to define meaningful names for the pins used in your sketches. This allows you to use the names that are the most meaningful in the context of that specific project (where you might well be using pin 56 for something completely different from the usage under which the "PCLK" name is relevant). Doing this is standard practice in any quality Arduino project.

Nowhere, unless you do it in your own code.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.