I am seeking HW.
I would like to make keyboard with enhanced functions (RGB backlite, macros, programmed profiles etc) driven by some small MCU (Arduino Micro Pro or something similar).
To support communication, it needs to use I2C and SPI(for display and other devices), use USB (to communicate with PC) and use Serial to communicate with other Arduinos/MCUs.
The main function would be scanning keyboard matrix (like from 8x8 to 16x8 in maximal variant). The matrix would use diodes for NKRO (not ghosting, any key combination possible).
It would be really nice to have HW, where I could use 3 full ports as input (or as output) with benefit of reading/writing them with only one assembly instruction for 8bit manipulation, not to cycle over array of pins and manipulate each one independently (digitalRead/digitalWrite, which use tons of instructions to determine ports and pin and then combine them together to obtain one 8bit variable). Something like:
byte dataout,datain1,datain2;
PORT_A=dataout;
datain1=PORT_B;
datain2=PORT_C;
Does anyone know, if there is such nonexpensive MCU and which type it is?
On typical Arduino each port is "poluted" by some importaint communications pins, so none of them can be used as full 8bit I/O.
Second question: Is there a reason, why are the most used communication pins spread over range of different ports and not collected on one port, while leaving other ports as full 8bit GPIO useable?
Thank for all answers.
2 Answers 2
I'd go with a Mega2560. Up to 86 IO if you use a board that breaks out all IO pins, otherwise 70 on the Arduino version. With a little attention to the physical chip pin mapping to the board you can have several full 8-bit ports while also using SPI, I2C, and Serial via one of 4 UARTs. I'd recommend keeping Tx(0)/Rx(0) free for comm's with PC via USB adapter for code download/debug. Tx1/Rx1, Tx2/Rx2, Tx3/Rx3 are them free for 0/5V level comm's, or other levels via USB adapter, RS232 adapter, etc.
The expander MCP23S17 (spi), with a CS, is a good extention (16 I/O configurable) That should do it !
LATE = dataout; datain = PORTB;
for example.