Not able to read the pin status in LPC 1114/302

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Not able to read the pin status in LPC 1114/302

Jump to solution
819 Views
monarchbaxi
Contributor II

Hi i am using LPC 1114/302 but i am not able to read the stauts of the Port Pin(P1_1 and P1_3)

Part of my code is as follows

#define LPC_GPIO                  ((LPC_GPIO_T             *) LPC_GPIO_PORT0_BASE)

typedef struct { /*!< GPIO_PORT Structure */
__IO uint32_t DATA[4096]; /*!< Offset: 0x0000 to 0x3FFC Data address masking register (R/W) */
uint32_t RESERVED1[4096];
__IO uint32_t DIR; /*!< Offset: 0x8000 Data direction register (R/W) */
__IO uint32_t IS; /*!< Offset: 0x8004 Interrupt sense register (R/W) */
__IO uint32_t IBE; /*!< Offset: 0x8008 Interrupt both edges register (R/W) */
__IO uint32_t IEV; /*!< Offset: 0x800C Interrupt event register (R/W) */
__IO uint32_t IE; /*!< Offset: 0x8010 Interrupt mask register (R/W) */
__I uint32_t RIS; /*!< Offset: 0x8014 Raw interrupt status register (R/ ) */
__I uint32_t MIS; /*!< Offset: 0x8018 Masked interrupt status register (R/ ) */
__O uint32_t IC; /*!< Offset: 0x801C Interrupt clear register (W) */
uint32_t RESERVED2[8184]; /* Padding added for aligning contiguous GPIO blocks */
} LPC_GPIO_T;

STATIC INLINE bool Chip_GPIO_GetPinState(LPC_GPIO_T *pGPIO, uint8_t port, uint8_t pin)
{
return (pGPIO[port].DATA[1 << pin]) != 0;
}

Chip_GPIO_GetPinState( LPC_GPIO, 1, 3)

this function always returns a zero value irrespective of the pin status

Pl guide

Labels (1)
0 Kudos
1 Solution
572 Views
monarchbaxi
Contributor II

Got the solution.... the problem was with configuring the pin ...the pin can also be used as analog pin and had to configure it to IOCON_DIGMODE_EN ......though the reset value for this pin is DIGITAL FUNCTION  MODE

Problematic code

Chip_IOCON_PinMuxSet( LPC_IOCON ,CONFIG_SENSOR ,( IOCON_FUNC1 | IOCON_MODE_PULLDOWN ));

working code

Chip_IOCON_PinMuxSet( LPC_IOCON ,CONFIG_SENSOR ,( IOCON_FUNC1 | IOCON_MODE_PULLDOWN | IOCON_DIGMODE_EN));

View solution in original post

0 Kudos
1 Reply
573 Views
monarchbaxi
Contributor II

Got the solution.... the problem was with configuring the pin ...the pin can also be used as analog pin and had to configure it to IOCON_DIGMODE_EN ......though the reset value for this pin is DIGITAL FUNCTION  MODE

Problematic code

Chip_IOCON_PinMuxSet( LPC_IOCON ,CONFIG_SENSOR ,( IOCON_FUNC1 | IOCON_MODE_PULLDOWN ));

working code

Chip_IOCON_PinMuxSet( LPC_IOCON ,CONFIG_SENSOR ,( IOCON_FUNC1 | IOCON_MODE_PULLDOWN | IOCON_DIGMODE_EN));

0 Kudos