This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Read value on EXT pin thingy 52

Hello.

I having problems with reading a value from one of the ext pins on thingy 52. (i can set the pin as output and toggle the pin from code.)

i have configured the pin as input. 

drv_ext_gpio_cfg_input(SX_IOEXT_1,DRV_EXT_GPIO_PIN_NOPULL);

I want to do something when the pin goes low, iam trying to read the pin value with the function  drv_ext_gpio_pin_read() but i doesent seem to get any reaction when changing from high to low on the pin. I dont really understand the second argument of the function drv_ext_gpio_pin_read() which might be the case why i dont get it to work.

I have tried the following code to check if i get stuck inside the loop when the input pin is high but it just get skipt indicating that the value from drv_ext_gpio_pin_read() is zero.

    while(drv_ext_gpio_pin_read(SX_IOEXT_1,0) != 0   ){

        //do nothing if high

    }
 

Thankful for help. 

//Rilleaa

Parents
  • Hi Rilleaa,

    I think you may have misunderstood the usage of this function drv_ext_gpio_pin_read(uint32_t pin_number, uint32_t * const p_pin). The second argument is passed in to store the pin levels. 

    If pin level is read successfully, drv_ext_gpio_pin_read will return DRV_EXT_GPIO_STATUS_CODE_SUCCESS (0x00), otherwise it will return values other than 0.

    Once this function returns SUCCESS, then you check the pin level stored in pointer p_pin.

    In case it still does not work, you can debug it by setting input pin with PULL UP and read the level again. It should be 1 in this case.

    Hope this will help you!

Reply
  • Hi Rilleaa,

    I think you may have misunderstood the usage of this function drv_ext_gpio_pin_read(uint32_t pin_number, uint32_t * const p_pin). The second argument is passed in to store the pin levels. 

    If pin level is read successfully, drv_ext_gpio_pin_read will return DRV_EXT_GPIO_STATUS_CODE_SUCCESS (0x00), otherwise it will return values other than 0.

    Once this function returns SUCCESS, then you check the pin level stored in pointer p_pin.

    In case it still does not work, you can debug it by setting input pin with PULL UP and read the level again. It should be 1 in this case.

    Hope this will help you!

Children
Related