If you are only reading from keypad pins, then you can create preprocessor macro, that will combine few pins from different ports to one "byte". Like this
// bits 0-1 are bits 3,4 from PORTA// ( (PORTA & ((1<<3)|(1<<4)) ) >> (3-0) )// bit2 is bit 0 from PORTB// ( (PORTB & (1<<0)) << (2-0) )// bits 34567 are bit 23456 from PORTE// ( (PORTE & ((1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)) ) << (3-2) )#define KEYPADPORT ( ( (PORTA & ((1<<3)|(1<<4)) ) >> (3-0) ) \ | ( (PORTB & (1<<0)) << (2-0) ) \ | ( (PORTE & ((1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)) ) << (3-2) ) )
Instead reading PTT you read KEYPADPORT.
Of course you can't write access KEYPADPORT, you need to code some function that would take byte and write all bits back to different ports.