I didnโt think Iโd need to say this, but apparently I do:
Donโt use the Raspberry Pi 2040 to build a DCC decoder.
Itโs not really wrong, of course, and it gives you ridiculous amounts of computing power, but to get that you need miles and miles of extra components. Like a dozen of decoupling capacitors, an external oscillator, and of course an external flash memory. You can maybe do that sort of thing in H0, but for real model trains, itโs just not ideal. Pick something like an ATTiny or STM32C0 (Iโve done both for different projects): Cheap, just one or two decoupling capacitors, no external oscillator required and no external flash memory needed either.
The versions of the RP2350 with built in memory may be a better idea, once they fix the GPIO issues anyway, but still, thereโs the oscillator and just way too many capacitors.
(Some of these concerns may be different if you want to add sound support, which requires more memory anyway. But Iโd argue that sound in model railroads is a mistake anyway. Iโve never seen an N scale locomotive that sounds good, itโs all just an annoying expensive gimmick.)
Also while weโre at it, donโt use a cheap standard bridge rectifier. The steep slopes of the DCC signal mandate a really fast rectifier, typically Schottky diodes. This is particularly important when you have RailCom on your layout. You may need four individual diodes instead of one rectifier, but since you wonโt need all the capacitors of the RP2040, you still win out in the end (itโs also typically smaller than the rather large SMD standard rectifiers).
This is a call-out post for https://github.com/gab-k/RP2040-Decoder . Itโs a useful project, but itโs also far from ideal.