How get the pin logic level when it configed as digital output

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

How get the pin logic level when it configed as digital output

682 Views
Dave_SU
Contributor III

Hi,

How to obtain the logic level of a GPIO pin when it is configured in the digital output mode.

Why is the state of GPIO pin always 0 when I do this.

EG:

    gpio_pin_config_t led_config = {
        kGPIO_DigitalOutput,
        0,
    };
    /* Init output LED GPIO. */
    GPIO_PortInit(GPIO, APP_BOARD_TEST_LED_PORT);
    GPIO_PinInit(GPIO, APP_BOARD_TEST_LED_PORT, APP_BOARD_TEST_LED_PIN, &led_config);
   
    GPIO_PinWrite(GPIO, APP_BOARD_TEST_LED_PORT, APP_BOARD_TEST_LED_PIN, 1);

    pin_state = GPIO_PinRead(GPIO, APP_BOARD_TEST_LED_PORT, APP_BOARD_TEST_LED_PIN);
    PRINTF("\r\n Standard port read: %x\r\n", pin_state);

 

Platform: MIMXRT595-EVK

SDK:SDK_2_11_1_EVK-MIMXRT595

Labels (1)
Tags (1)
0 Kudos
4 Replies

675 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @Dave_SU ,

  About the pin logic leave, you can find it from the datasheet:

kerryzhou_0-1654072380046.png

  Do you test this SDK code for the SW input:

SDK_2_11_1_EVK-MIMXRT595\boards\evkmimxrt595\driver_examples\gpio\led_output

  This should works.

   About your mentioned led output, then read it for the input, you need to check the pin level from the hardware, whether it meet the H level voltage: >0.7vdd, maybe due to the HW, the level didn't match it, you can control one pin which didn't connect to a lot of circuit, that will be more easy to test.

Best Regards,

Kerry

 

0 Kudos

661 Views
Dave_SU
Contributor III

Hi @kerryzhou 

Thank you for your reply.

SDK_2_11_1_EVK-MIMXRT595\boards\evkmimxrt595\driver_examples\gpio\led_output

When I execute below code,  I can get the SW_GPIO input level (swpressed  is 0 or released is 1).    
       pin_state = GPIO_PinRead(GPIO, APP_SW_PORTAPP_SW_PIN); 
       PRINTF("\r\n APP_SW_PIN level = : %x\r\n", pin_state );
But when I did the same action, shown as below. The pin_level(whether it's written 0 or 1) always equal to logic 0.
       pin_state =  GPIO_PinRead(GPIO, APP_BOARD_TEST_LED_PORT, APP_BOARD_TEST_LED_PIN);
       PRINTF("\r\n APP_BOARD_TEST_LED_PIN  level = : %x\r\n", pin_state );
 
Note: APP_SW_PIN was configed as input mode and APP_BOARD_TEST_LED_PIN as output mode.
0 Kudos

658 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @Dave_SU ,

  Yes, I know the SDK is input, just check with you whether that can get the correct level.

  Please test SW_GPIO, configure it as output, whether you can get the correct level or not?

   Or you can test your TEST_LED pin, when it is output 1, what's the pin voltage. and output 9, what's the voltage?

  Just make sure the external circuit output voltage is really higher than 0.7vdd, which can be recognized as high to the input.

  Please test it, and share me the result.

  As I am working at home, and lack the board for testing now.

  Thanks a lot for your understanding.

Best Regards,

Kerry

0 Kudos

648 Views
Dave_SU
Contributor III

@kerryzhou 

Thanks a lot, Please let me try it as your menthoned.

Best wishs.

0 Kudos