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

How can I detect the state of an LPCOMP input?

I am programming a device with a NF52 that uses a hall effect switch o enter/exit sleep mode when BLE is in advertising mode. When connected, It will generate a separate BLE notification for the condition that a magnet is present or not.

I have the LPCOMP set to generate an interrupt on a CROSS event. My handler has code for the cases of an UP or DOWN event, but this doesn't seem to work.

if (event == NRF_LPCOMP_EVENT_DOWN) { ...do something }

if (event == NRF_LPCOMP_EVENT_UP) { ...do something }

I've also tried configuring the pin as an output and reading its state, but this does not work either. How can test if a pin is low or high when set to trigger an LPCOMP interrupt when the state changes?

Parents
  • Not according to the nrf52 Product Specification:

    The LPCOMP will generate events every time VIN+ crosses VIN-. More specifically, every time VIN+ rises above VIN- (upward crossing) an UP event is generated along with a CROSS event. Every time VIN+ falls below VIN- (downward crossing), a DOWN event is generated along with a CROSS event.

    But in reality it seems to be the way Sigurd said, you only get an CROSS event. Can someone from Nordic clarify this?

Reply
  • Not according to the nrf52 Product Specification:

    The LPCOMP will generate events every time VIN+ crosses VIN-. More specifically, every time VIN+ rises above VIN- (upward crossing) an UP event is generated along with a CROSS event. Every time VIN+ falls below VIN- (downward crossing), a DOWN event is generated along with a CROSS event.

    But in reality it seems to be the way Sigurd said, you only get an CROSS event. Can someone from Nordic clarify this?

Children
No Data
Related