Hi
I don't see a further error so I have attached a binary file that you can copy to your board to show it working:
1. Beware that PTD2 on the FRDM-KEA128Z board is connected to the output of the MCZ33903CD's SPI (U16) so it will be held low. It is best to remove R65 so that it is then connected only to the connector J6-2 (if not removed you need to apply VDD to J6-2 to get the input to change to '1').
2. The program will flash the green LED when PTD2 is '1'. When PTD2 is '0' it will flash it between yellow/red instead.
The code that I use is
_CONFIG_PORT_INPUT(A, KE_PORTD_BIT2, PORT_PS_UP_ENABLE);
for the input's initialisation
and
extern void fnQuickTask2(TTASKTABLE *ptrTaskTable) // polling task (equivalent to while(1))
{
if (_READ_PORT_MASK(A, KE_PORTD_BIT2) != 0) {
_SETBITS(B, KE_PORTH_BIT0);
}
else {
_CLEARBITS(B, KE_PORTH_BIT0);
}
}
to poll the input and set the yellow LED accordingly.
Since you are not using the uTasker project where this is easy to do (the macros handle all the details and differences between chips) you can compare your code with the code that the macros are creating in the case of the KEA128, which is:
GPIOA_PIDR &= ~(KE_PORTD_BIT2);
GPIOA_PDDR &= ~(KE_PORTD_BIT2);
PORT_PUE0 |= KE_PORTD_BIT2;
if (GPIOA_PDIR & (KE_PORTD_BIT2)) {
FGPIOB_PSOR = KE_PORTH_BIT0;
}
else {
FGPIOB_PCOR = KE_PORTH_BIT0;
}
On the OpenDA VCOM there is a command line interface (115'200Baud) which has some menus. In the I/O menu (3) there is a memory debugger so that you can also read registers in case that helps you find a difference.
My feeling is however that you may be making a measurement error and your PTD2 is being held at '0' by the other chip on the board.
Regards
Mark
P.S. You can get a complete FRDM-KEA128 solution at the uTasker OpenSource project, including S32 project and KEA128 simulation - http://www.utasker.com/kinetis/FRDM-KEAZ128Q80.html
uTasker developer and supporter (+5'000 hours experience on +60 Kinetis derivatives in +80 product developments)
Kinetis: http://www.utasker.com/kinetis.html