"Chip_GPIO_GetPinState" not working

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

"Chip_GPIO_GetPinState" not working

跳至解决方案
1,941 次查看
sagarpatil
Contributor II

Hi All and  lpcware,

I am using LPC43S67 EVM board,

in my project i have to read sensor digital input,

so i am using following code to test GPIO functionality :-

#include <board_api.h>
#include <chip.h>
#include <chip_lpc43xx.h>
#include <gpio_18xx_43xx.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

int main(void)
{
    SystemCoreClockUpdate();
    Board_Init();                                                                                                                    //Chip_GPIO_init does nothing

//    Chip_SCU_PinMuxSet(0x1,0x13,SCU_MODE_INBUFF_EN);                                    //P1_13==GPIO1[6] from UM10503
//    Chip_SCU_PinMux(0x1,0x13,SCU_MODE_INBUFF_EN,SCU_MODE_FUNC0);

    

Chip_GPIO_SetPinDIR(LPC_GPIO_PORT,0x1,0x6,false);                                             //input   GPIO1[6]
    while(1)
    {
        if(Chip_GPIO_GetPinState(LPC_GPIO_PORT,0x1,0x6))
        {
            Chip_GPIO_SetPinState(LPC_GPIO_PORT,0x0,0x7,false);                                 //set GREEN led
        }
        else
        {
            Chip_GPIO_SetPinState(LPC_GPIO_PORT,0x3,0x7,false);                                  //set RED led
        }
    }
return 0;
}

but Chip_GPIO_GetPinState always returns "false",

i have connected 3.3v also on P1_13 also but still returns "false",

any help?

thanks and regards,

sagar
 

标签 (4)
标记 (3)
0 项奖励
回复
1 解答
1,290 次查看
sagarpatil
Contributor II

Hi all,

below code is working for me,

#include <board_api.h>
#include <chip.h>
#include <chip_lpc43xx.h>
#include <gpio_18xx_43xx.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
int main(void)
{
    SystemCoreClockUpdate();
    Board_Init();                                                                            //Chip_GPIO_init does nothing

    Chip_SCU_PinMuxSet(1,13,SCU_MODE_INBUFF_EN);     //for SCU functionality use P1_13

    while(1)
    {
        if(Chip_GPIO_GetPinState(LPC_GPIO_PORT,1,6))        for GPIO functionality use GPIO1[6]
        {
            Chip_GPIO_SetPinState(LPC_GPIO_PORT,0,7,false);
        }
        else
        {
            Chip_GPIO_SetPinState(LPC_GPIO_PORT,3,7,false);
        }
    }
}

Thanks for the help,

sagar

在原帖中查看解决方案

1 回复
1,291 次查看
sagarpatil
Contributor II

Hi all,

below code is working for me,

#include <board_api.h>
#include <chip.h>
#include <chip_lpc43xx.h>
#include <gpio_18xx_43xx.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
int main(void)
{
    SystemCoreClockUpdate();
    Board_Init();                                                                            //Chip_GPIO_init does nothing

    Chip_SCU_PinMuxSet(1,13,SCU_MODE_INBUFF_EN);     //for SCU functionality use P1_13

    while(1)
    {
        if(Chip_GPIO_GetPinState(LPC_GPIO_PORT,1,6))        for GPIO functionality use GPIO1[6]
        {
            Chip_GPIO_SetPinState(LPC_GPIO_PORT,0,7,false);
        }
        else
        {
            Chip_GPIO_SetPinState(LPC_GPIO_PORT,3,7,false);
        }
    }
}

Thanks for the help,

sagar