I've noticed that whenever I look at a microcontroller or SoC I might wish to use, especially the reduced-pin non-BGA versions, some of the more interesting peripherals are effectively mutually exclusive because of limited available pins. To solve this, I created a tool, of course.
However, I'm wondering if you too have encountered this issue, and would like a semi-interactive browser-based local tool (no server, no internet connection needed, CC0/Public Domain license so you can modify it to your liking) for this, in the same vein as my
FIR filter spectrum analysis or
Advantest horizontal scaling and palette test pages.
The algorithm is a simple, deterministic, fast, and recursive; well suited for JS in a browser, finding solutions in a fraction of a second even on slow devices. On each iteration, it first checks if any of the facilities needed has only one pin choice left, and assigns them, removing it from the other facilities' lists. If it runs out, it tells which facilities conflicted (and ran out of pins). Otherwise, it repeats this as long as pins can be assigned. Then, it collects the undetermined ones and their leftover options.
I was thinking the tool could then present these as drop-down lists, where you need to assign at least one to proceed (but can assign all if you want). It then repeats this (presenting further choices if necessary), until the pin configuration is fully determined (or runs out of pins, in which case you can change your choices before). Finally, it presents the determined pin set, in both sorted pin order, and in sorted facility order.
As a practical example, consider STM32H7A3RIT or STM32H7A3RGT (
datasheet) in LQFP-64. Let's say you're helping
@Tantratron with the display replacements for some Advantest spectrum analyzers, and you wish to use AT056TN53v1 display at 640×480 resolution, and the parallel PSSI 8-bit input.
Essentially, you want USB (DM and DP for firmware updates), 8-bit PSSI, and LCDC. Is it possible or not?
If you want a pure RGB888 or RGB565 output, it turns out it is not. However, if you don't mind skipping some color component bits on the output (which is not a problem if you use L8 or A44 byte-per-pixel modes with palette look-ups, and don't need to do pixel color math at all), it can; for example,
SWCLK 49:PA14
SWDIO 45:PA13
USB_DM 43:PA11
USB_DP 44:PA12
LCD_VSYNC 23:PA7
LCD_HSYNC 37:PC6
LCD_DE 25:PC5
LCD_CLK 35:PB14
LCD_R1 16:PA2
LCD_R2 15:PA1
LCD_R4 21:PA5
LCD_R5 8:PC0
LCD_R6 53:PC12
LCD_R7 24:PC4
LCD_G0 27:PB1
LCD_G1 26:PB0
LCD_G4 29:PB10
LCD_G5 9:PC1
LCD_G6 38:PC7
LCD_G7 36:PB15
LCD_B1 51:PC10
LCD_B2 17:PA3
LCD_B3 40:PA8
LCD_B5 57:PB5
LCD_B6 50:PA15
LCD_B7 54:PD2
which leaves a couple of PWM-capable pins and ordinary GPIO pins (for backlight and orientation on the display), but also the SWDIO, SWCLK, and USB FS pins free for very easy reprogramming. (When the BOOT0 is pulled high when plugging in the USB, it boots up in ARM DFU firmware upload mode.) The logical use is on the left, and the
LQFP64pin:
name is on the right; but you can use any pin naming scheme you want.
Note that 8-bit red (
R), green (
G), and blue (
B) components are stored as
Rfb,
Gfb,
Bfb in the framebuffer and LUTs, where
Rfb = ((R >> 1) & 0x06) | (R & 0xF0) Gfb = ((G >> 2) & 0x03) | (G & 0xF0) Bfb = ((B >> 1) & 0x0E) | (B & 0xE0)but you do have full 18-bit color (262,144 colors) with the LCDC is configured to output RGB888. Again, if you just use predefined colors and don't do blending, everything will work just fine; it's just that blending colors due to the above won't work right (either in hardware or in software): you would have to do the reverse of the above (and replicate the two LSBs) first, then do the blending, then redo the above. Doable, but too annoying in practice.
Of course, right now the LQFP-100 version (STM32H7A3VxT) is cheaper than the LQFP-64 version at Mouser right now (with none in stock at Digikey), so this is a bit silly example; but illustrates the type of problem this tool solves.
If you want to try it out first, the very crude prototype (working) command-line, text-based implementation in Python3 is attached. Again, if there is interest, I'd rather make this into a tool page for portability and nice-GUI ease-of-use. It does assume each pin can be individually assigned, so won't work for some MCUs like most WCH-IC RISC-V ones (which configure pins as sets, not individually).