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

LPCOMP to GPIO pin nrf51

Hallo everyone. I'm working with the processor nRF51422 with S210 softdevice and I would like to ask you if it's possible to drive results of LPCOMP to a General-purpose I/O pin (GPIO). My purpose is to have a low output on GPIO pin when the signal from LPCOMP is above to the threshold value, and vice-versa when the signal from LPCOMP is below the threshold value (so, in other words, the function of an inverting comparator). Another thing I need to know is the maximum allowed frequency of the input signal in this configuration. Thank you.

Parents
  • Hi.

    You can use PPI channels by configuring the LPCOMP to trigger an event when your VIN is crossing some reference voltage level. This event can then be connected via a PPI channel to trigger a task in the GPIOTE module and e.g. toggle a pin. I have attached an example setting up an application like this.

    However, there is a catch. In this example the event is triggered on every crossing of the reference voltage and the GPIOTE pin is set to 'high' as the initial logic value. Hence, whether the GPIO pin is inverting or following the VIN signal depends on the startup level of VIN. I don't have the time to look into this problem, but you can investigate if you can configure the GPIOTE and LPCOMP in a different manner or maybe you can use additional PPI and GPIOTE channels to do some magic. A more complicated solution might be to use the ADC and measure the initial voltage level of VIN and then after that configure the GPIOTE pin with the correct initial logic level.

    Example. Based on SDK V9 and tested on a nRF51 DK without any softdevice.

Reply
  • Hi.

    You can use PPI channels by configuring the LPCOMP to trigger an event when your VIN is crossing some reference voltage level. This event can then be connected via a PPI channel to trigger a task in the GPIOTE module and e.g. toggle a pin. I have attached an example setting up an application like this.

    However, there is a catch. In this example the event is triggered on every crossing of the reference voltage and the GPIOTE pin is set to 'high' as the initial logic value. Hence, whether the GPIO pin is inverting or following the VIN signal depends on the startup level of VIN. I don't have the time to look into this problem, but you can investigate if you can configure the GPIOTE and LPCOMP in a different manner or maybe you can use additional PPI and GPIOTE channels to do some magic. A more complicated solution might be to use the ADC and measure the initial voltage level of VIN and then after that configure the GPIOTE pin with the correct initial logic level.

    Example. Based on SDK V9 and tested on a nRF51 DK without any softdevice.

Children
Related