AnsweredAssumed Answered

Problem in reading input from gpio pin in frdm-kea128

Question asked by Tejas R on May 9, 2018
Latest reply on May 15, 2018 by Shravan Srinivasa

Hey, I'm new to frdm boards. I'm currently using S32 DS for my programming. I wanted to start using this board and i set up a basic code to test it. I wanted to use port d2(PTD2) as input and port d3(PTD3) as output. But i'm unable to read anything from port d2 (PTD2). I used the onboard led on PTE7 for verification. In debugging mode, the program flow is not entering the if statement even if the voltage there is high(i verified through dmm). Is there any problem with the header file? The code i used is: 

 

#include "derivative.h" /* include peripheral declarations SSKEAZ128M4 */
#define PTD2 26 //input
#define PTD3 27 //output
#define PTE7 7 //TESTING


int main(void)
{

GPIOA_PDDR &= ~(1<<PTD2);  //Setting PTD2 as input. IS this right?
GPIOA_PIDR &= ~(1<<PTD2);
PORT_PUE0 |= 1<<PTD2;

 

GPIOA_PDDR |= 1<<PTD3;  //Setting Ptd3 as output
GPIOA_PIDR &= 1<<PTD3;


GPIOB_PDDR |= 1<<PTE7; //Setting PTE7 as output
GPIOB_PIDR &= 1<<PTE7;


for(;;){
GPIOB_PSOR |= 1<<PTE7;
if( (GPIOB_PDIR) & (1<<PTD2)) // Program is not entering the if condition. Jumping directly to else condition
{
GPIOA_PCOR |=1<<PTD3;
}
else{
GPIOA_PSOR |= 1<<PTD3;
}
GPIOB_PCOR |= 1<<PTE7;
}

}

Outcomes