Ah, the N64 controller. An exercise in learning. I’ll be straight with you, I didn’t do this right. I started this project at a time when I didn’t know all that much about what I was doing. But I think it was the best possible way for me to jump in and learn a lot all at once. But as a learning experience, it was full of errors. Lets go down the list.
Interrupts are the way a game controller should be done. When I planned this out, I was going to scan all the buttons continuously. This sucks. Scanning continuously means that the microcontroller can never be put in a sleep mode, meaning battery life will be terrible. There’s also a chance that a button input could be missed. In this case, the 328P has 3 pin change interrupt flags covering pins 23-16, 14-8, 7-0. Each flag covers 7 or 8 pins, for 23 total (what’s up with 15? It isn’t listed). We lose one of those as a reset pin. Two more of those are lost to a crystal input. So now we’ve got 20 total. The N64 has 14 buttons. We need two ADC pins for the joystick, and 3 or 4 more for SPI (Depending on if you use SS or not, but it isn’t needed since there’s only one slave). We’re now need 19 or 20 pins. Just enough for the 328P. But the interrupts are enabled for whole ports, so we have to line up the ADC and SPI pins on one port. This could work. But I unfortunately didn’t set up my board with this in mind. I could also use a TCA8418 from Texas Instruments. This would support up to 80 buttons in an 8x10 keypad, a bit overkill.
My layout was poorly done. I had right angle traces, which is a layout no-no. The additional lines for pullups clogged up the board. There are a few places where many small traces are side by side, which allowed them to short or be scratched off.
The traces were really small to fit near the smaller ICs. I really should have made the traces thicker. The problem is that these traces are so thin, they can be scratched off with a soldering iron on accident. The real issue here is that I don’t have a solder mask. With a mask, the clearances can be tighter without worrying about solder bridges. As it stands, its bridge city. This is another reason why professional boards are probably better.