ADICUP 360: How to Digital Read Value of GPIO Pin

Hey there,

I want to connect my ADCIUP360 to a switch so that whenever the switch is turned On or OFF the value of a variable can be modified. However I am unable to read whether the Pin is High or Low. There is a function in DioLib.c that says that it reads value of pin but I am unable to read its output as I am printing it on Serial using Putty but it returns empty.

/**
@brief uint32_t DioRd(ADI_GPIO_TypeDef *pPort)
========== Reads values of port pins.
@param pPort :{pADI_GP0,pADI_GP1,pADI_GP2}
- pADI_GP0 for GP0.
- pADI_GP1 for GP1.
- pADI_GP2 for GP2.
@return value on port pins.
**/
uint32_t DioRd(ADI_GPIO_TypeDef *pPort)
{
return (pPort->GPIN);
}

Kindly help me with this function as it also does not specifies the pin number to be read.

Parents
  • Hello,

    Which pin are you trying to use? Note that pin 7 from port 0 needs to be configured as GPIO before trying to read it because the default configuration is nPOR.

    Also make sure the output is not enabled and open circuit is not enabled for that pin because the read state is not available in this case.

    To use this function just give it the pointer to the port you want to read:

    • pADI_GP0 for port 0;
    • pADI_GP1 for port 1;
    • pADI_GP2 for port 2.

    The return value of the function is the content of the 'IN' register. You need to mask that value with (1 << pin_number) to get only the result of the intended pin. If it is '1' the pin is HIGH, else it is LOW.

    Let me know if anything is still unclear.

    Regards,

    Andrei.

Reply
  • Hello,

    Which pin are you trying to use? Note that pin 7 from port 0 needs to be configured as GPIO before trying to read it because the default configuration is nPOR.

    Also make sure the output is not enabled and open circuit is not enabled for that pin because the read state is not available in this case.

    To use this function just give it the pointer to the port you want to read:

    • pADI_GP0 for port 0;
    • pADI_GP1 for port 1;
    • pADI_GP2 for port 2.

    The return value of the function is the content of the 'IN' register. You need to mask that value with (1 << pin_number) to get only the result of the intended pin. If it is '1' the pin is HIGH, else it is LOW.

    Let me know if anything is still unclear.

    Regards,

    Andrei.

Children