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.