I have some E73-2G4M08S1C modules, basically a nRF52840 chip with the basic components around it, including a crystal and antenna. They are small and very low power SMD BLE devices.
I cant read or write to the GPIO pins!
I am now able to run apps (thanks to the help of @maxgerhardt on my post friday) and to use the BLE function (Adafruit libs). However, I am not able to write to any of the GPIO pins, it seems. They just stay floating. I use the program below, where I excluded all BLE (and PIR) functions, and only alternate 3 pins. PIN_DJ is now 42 = P1.10 (is it?), PIN_NFC1 en 2 are 9 = P0.09 and 10 = P0.10. The monitor shows the alternating text, but the pins do nothing.
I learned that the bootloader is not relevant to this, that the application can set the usage of the pins. Is that right? Is there more settings somewhere?
Does anyone know what I miss this time?
void setup()
{
Serial.begin(115200);
#if CFG_DEBUG
// Blocking wait for connection when debug mode is enabled via IDE
while ( !Serial ) yield();
#endif
Serial.println("Bluefruit52 BLEUART Example");
Serial.println("---------------------------\n");
//setupPir();
//setupBLE();
pinMode(PIN_DJ, OUTPUT);
pinMode(PIN_NFC1, OUTPUT);
pinMode(PIN_NFC2, OUTPUT);
}
uint32_t mLoop=0;
bool bLoop=true;
void loop()
{
//loopPir();
//loopBLE();
if (millisPast(mLoop, 1E3))
{
bLoop = !bLoop;
if (bLoop) {
//sendMessage("Blink ");
Serial.print("Blink");
digitalWrite(PIN_DJ, HIGH);
digitalWrite(PIN_NFC1, HIGH);
digitalWrite(PIN_NFC2, HIGH);
} else {
//sendMessage("Black ");
Serial.print("Black");
digitalWrite(PIN_DJ, LOW);
digitalWrite(PIN_NFC1, LOW);
digitalWrite(PIN_NFC2, LOW);
}
}
}
Assuming you’re using board = adafruit_feather_nrf52840_sense in your platformio.ini, you have the pin mapping of that variant, which has the pin mapping of
which in turn are indices into the g_ADigitalPinMap array at index 2 and 33, e.g., with PIN_NFC2 = 2,
which should be P0.10.
Each numerical value “n” in that array maps to the “Px.y” format by means of
x = n // 32
y = n % 32
(i.e., being the divisor and remainder of 32)
Index 42 by default does not exist in that array, since everything after D36 is commented out. So you should not use that index.
The P1.10 is mapped as “D4” (4th index in the array), and also known under the macro LED2. So you should be able to use pinMode(4, OUTPUT); digitalWrite(4, HIGH); to affect P1.10.
Another point of failure is a that a pin is not properly soldered between the module and carrier board, or that something is wrongly labeled. P1.10 is pyhsically found as pin number 2 on that module.
Thanks again, @maxgerhardt. This solves the issue. There is a translation-table and the ‘pinnumber’ to use in pinMode and digitalWrite is NOT the PX.0Y number but the index to the translation table. Thanks again for your help!