Reading port pins in FX2LP

Question: How to read ports pins in FX2LP?

 

Answer:

Consider that PORT C has to be configured as input port and its data has to be read. The below code configure PORT C as input port and reads the PORTC pins.

 
BYTE pinData;
PORTCCFG = 0x00;            // PORTC is is configured as an I/O 
OEC = 0x00;                    // PORTC is an input
pinData = IOC;                 // Reading the Port C pins