AnsweredAssumed Answered

problem in GPIO reading

Question asked by Aravind palanisamy on Jul 29, 2019
Latest reply on Jul 30, 2019 by Sabina Bruce

   I try to read a gipo pin status either 0 or 1 in digital form but when i try to read my assigned pin was not getting o/p 

please let me know the solution . in below i provided the code 

 

/*
* Copyright (c) 2016, Freescale Semiconductor, Inc.
* Copyright 2016-2019 NXP
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

/* Standard C Included Files */
#include <stdio.h>
#include <string.h>
#include "board.h"
#include "fsl_debug_console.h"
#include "fsl_i2c.h"
#include "fsl_i2c.h"
#include <stdlib.h>
#include <string.h>
#include "pin_mux.h"
#include "fsl_device_registers.h"
#include "fsl_common.h"
#include"lpc8xx_i2c.h"
#include"fsl_usart.h"
/*******************************************************************************
* Definitions
******************************************************************************/

#define BOARD_LED_PIN 23U
#define SWITCH_PORT 0U
#define SWITCH_PIN 28U


static void EXAMPLE_USARTInit(void);
void delay_ms(int a);

 

int main(void)
{

 

gpio_pin_config_t led_config = {kGPIO_DigitalOutput, 0,};
gpio_pin_config_t SWITCH_config = { kGPIO_DigitalInput, 0,};


GPIO_PortInit(GPIO, BOARD_LED_PORT);
GPIO_PinInit(GPIO, BOARD_LED_PORT, BOARD_LED_PIN, &led_config);

GPIO_PortInit(GPIO, SWITCH_PORT);
GPIO_PinInit(GPIO, SWITCH_PORT, SWITCH_PIN, & SWITCH_config);

 

while(1)
{
while(GPIO_PinRead(GPIO,SWITCH_PORT, 1u << SWITCH_PIN)==1);

 

 

 

GPIO_PortToggle(GPIO, BOARD_LED_PORT, 1u << BOARD_LED_PIN);

} // end of while 1

} // end of main

 

 

 

static inline uint32_t GPIO_PinRead(GPIO_Type *base, uint32_t port, uint32_t pin)
{
return (uint32_t)base->B[port][pin];
}

Outcomes