Thanks to me being a bit blind and also to Atmel Studio 6.2 masking a source code error, I've spotted a few issues and corrected them.
Here's the new source code and circuit diagram.
Attachment:
kybd2.jpg [ 124.03 KiB | Viewed 1643 times ]
Attachment:
GccApplication7.zip [23.31 KiB]
Downloaded 69 times
I've also run into an issue that Michael kindly pointed out to me, although I think it's a slightly different one than initally thought (correct me if I'm wrong, Michael).
When I press two keys on the same row as each other, I get a large pull on the power rail. If press three keys together, I get even more pull.
Here's what happens when keys are pressed and held down on the same row. Note that keys pressed at the same time on different rows do not cause issues:
Resting current use: alternates between 3 and 5mA
1 key pressed: 3mA (does not rise to 5mA)
2 keys pressed together: 37mA (+34mA)
3 keys pressed together: 55mA (+18mA)
4 keys pressed together: 72mA (+17mA)
The above does not differ if different key combinations are used.
The way my keypad circuit works is that it holds all rows HIGH by default
When a row is being scanned, it drops that row LOW.
The Column inputs are then checked to see if a LOW is detected on a column and if so, the row/column number combination is recorded, the ascii value looked up and outputted on the VIA interface pins (along with the VIA IRQ dropping LOW for 10ms).
The column lines are held high using a 10K bus resistor network connected to +5v rail.
I don't understand why there is this power draw? Can anyone see from my diagram if I've mucked something up? If it were completely shorting out then my benchtop PSU would go to the max allowed current and then start dropping the voltage. This doesn't happen.