Digital and Analog Pins
The Neuro N6 header pins, their capabilities, and the 1.8 V analog reference.
The Neuro N6 header uses Arduino Nano style D and A pin names. The standard functions pinMode, digitalWrite, digitalRead, digitalToggle, analogRead, analogWrite, tone, pulseIn, shiftIn and shiftOut are implemented. Two properties differ from 5 V Arduino boards:
- Digital logic is 3.3 V. No header pin tolerates 5 V.
- Analog full scale is 1.8 V. Inputs above approximately 1.79 V read 4095, and the datasheet requires analog inputs to remain below the analog supply.
Pin table
| Name | MCU pin | Analog | PWM | Notes |
|---|---|---|---|---|
D0 | PD0 | Header RX. UART4 when the LTE library is linked | ||
D1 | PD1 | Header TX | ||
D5 | PE9 | yes | ||
D6 | PF5 | |||
D9 | PD12 | Shares an interrupt line with A2 | ||
D10 | PF10 | SS by convention | ||
D11 | PF15 | |||
D12 | PA3 | |||
D13 | PG14 | |||
A0 | PF13 | yes | ||
A1 | PF11 | yes | ||
A2 | PF12 | yes | Shares an interrupt line with D9 | |
A3 | PF3 | yes | ||
A4 | PF14 | yes | yes | |
A5 | PG15 | yes | Conventional SD card chip select | |
SDA | PD15 | Header I2C, 3.3 V, 4.7k pull-ups | ||
SCL | PD14 | Header I2C | ||
MOSI | PD7 | SPI2 | ||
MISO | PD11 | SPI2 | ||
SCK | PF2 | SPI2 | ||
LEDR | PE11 | yes | RGB LED red, active low | |
LEDG | PD6 | yes | RGB LED green, active low. Aliased as LED_BUILTIN | |
LEDB | PC1 | yes | RGB LED blue, active low | |
BTN_USER | PG8 | External 10k pull-down. Reads HIGH while pressed |
All pins in the table are digital capable. D2, D3, D4, D7 and D8 are not routed; their table entries are placeholders so that pin numbers match their names. Pins used by the camera, display, USB and external flash are not exposed.
Analog input
void setup() {
Serial.begin(115200);
analogReadResolution(12); // 0 to 4095
}
void loop() {
int raw = analogRead(A0);
int mv = (raw * 1800) / 4095; // 1.8 V full scale
Serial.print(raw); Serial.print(" "); Serial.print(mv); Serial.println(" mV");
delay(200);
}The reference is the VDDA_1V8 rail, measured at approximately 1.79 V from the factory calibration word. The STM32N6 datasheet specifies the ADC input range as VSSA to VREF+, and on this board VREF+ is the 1.8 V analogue supply, which is the origin of the limit. The converters are two 12-bit successive approximation ADCs rated at up to 5 Msps with a hardware oversampler; the default resolution is 10 bits for Arduino compatibility, and analogReadResolution(12) selects the native range.
Voltage division. Signals above 1.8 V must be divided. For a single cell lithium polymer battery, a 100k over 51k divider with 100 nF from the tap to ground gives a 1:3 ratio and keeps 4.3 V within range. For a 3.3 V signal, 100k over 100k gives 1.65 V at full scale.
Digital output
pinMode(pin, OUTPUT) followed by digitalWrite. digitalToggle(pin) inverts a pin in one call. The board datasheet specifies a GPIO voltage range of -0.3 to 3.6 V and a current limit of 4 mA per pin. The STM32N6 I/Os are capable of up to 20 mA depending on the speed setting; the board rating is the design limit.
OUTPUT_OPENDRAIN configures a pin that only pulls low. When released the pin is high impedance and an external pull-up sets the level. This is the correct mode for the power key of a cellular modem.
Digital input
INPUT, INPUT_PULLUP and INPUT_PULLDOWN are supported. The USER button has an external pull-down and is read with plain INPUT: HIGH while pressed, LOW when released.
PWM
analogWrite produces hardware PWM on D5, A4 and the three LED channels at 1 kHz by default. The board datasheet lists D5, D10, D12 and D13 as PWM capable pins; the core implements analogWrite on D5, A4 and the LED channels. analogWriteFrequency(hz) sets the frequency and analogWriteResolution(bits) the range. digitalPinHasPWM(pin) reports capability at run time. Because the LEDs are active low, a larger value dims them.
tone() and noTone() work on any digital pin and do not require a PWM capable pin. PWM is generated by the STM32N6's general purpose timers, which are clocked at up to 240 MHz.
Interrupts
attachInterrupt(digitalPinToInterrupt(BTN_USER), onPress, RISING);RISING, FALLING and CHANGE are supported. digitalPinToInterrupt(pin) returns the pin number unchanged.
Each pin is connected to one of sixteen external interrupt lines, selected by its pin number within its port. Two pins with the same number in different ports cannot both have interrupts attached. On this header, A2 (PF12) and D9 (PD12) share line 12; the second attachInterrupt prints a warning and has no effect. No other header pins collide.
Handlers run in interrupt context. Shared variables are declared volatile.
Pulse and shift functions
pulseIn(pin, level, timeout) measures a pulse in microseconds. shiftIn and shiftOut clock bytes on any two pins. Both are the reference Arduino implementations.
Pin constants
LED_BUILTIN is a macro, so that #ifdef LED_BUILTIN works in existing sketches. The remaining pin names are typed constants rather than macros, because a macro named A0 collides with a structure member in the CMSIS DSP headers. Typed constants cannot be used in preprocessor #if tests; a sketch that needs a pin number in one uses the raw value, for example 18 for A4.