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

LPComp events triggers by other inputs

Hi

I am currently doing a project based on the nRF52840 MCU and evaluation board

as part of my project, I have used the LPComp module, and set it up to trigger on rising voltage

#define LPCOMP_REF				NRF_LPCOMP_REF_EXT_REF0			//AIN0
#define AUD_DET					NRF_LPCOMP_INPUT_1				//AIN1

    nrf_drv_lpcomp_config_t config = NRF_DRV_LPCOMP_DEFAULT_CONFIG;
	nrf_lpcomp_config_t		hal_config;

	hal_config.reference	= LPCOMP_REF;
	hal_config.detection	= NRF_LPCOMP_DETECT_UP;
	hal_config.hyst			= NRF_LPCOMP_HYST_NOHYST;

	config.hal		= hal_config;
	config.input	= AUD_DET;

	// initialize LPCOMP driver, from this point LPCOMP will be active and provided
	// event handler will be executed when defined action is detected
	errorCode = nrf_drv_lpcomp_init(&config, lpcomp_event_handler);
	APP_ERROR_CHECK(errorCode);

	nrf_drv_lpcomp_enable();

I have done so by following the LPComp example of the 15.3 SDK, which my project uses

I have tested the module and it seems to work

however, I am also recording LPComp events triggering when other modules are used (for example, when using LEDs or other GPIOs)

I have tried connecting both references together, grounding both, yet I still get LPComp events

I have also tested on two evaluation boards, so I know that the one I normally use isn't just faulty (unless both are faulty somehow)

Is there any reason for this behavior? anything I could test to try and figure out the cause?

if there is any more information I can provide to help with solving this, please let me know and I'll do my best to provide it

thanks in advance

  • Hi,

    Which GPIOs are you using for the other modules that trigger the events?

    Can you provide a full project that can be used to reproduce this behavior?

    Best regards,
    Jørgen

  • the LEDs trigger these events, and the LEDs are configured normally on the evaluation board (the BSP_LED_X GPIOs)

    I can try to provide the full project, if there is some way to send it your way (it's currently in SES, though I doubt that would cause issues)

    let me know which method would be most comfortable for you

  • Ok, these pins should not overlap with the analog inputs. You can upload a zipped version of the project as an attachment to your comment/answer here (Insert -> Insert image/video/file). If you do not want to post the code in public, I can convert the case into a private one.

  • Sosense_POC.7z

    what you are looking for is the sosense.emProject file (I recently ported to SES)

    you may need to comment out some code, as it is expecting some peripherals, though it may work without any changes (please verify that nrf_drv_lpcomp_disable() is commented out in sosense_lpcomp_drv.c)

    I noticed that in normal mode, pressing button 2 generates the event (I added the effect of LED 3 lighting for 0.5s when the event is sent)

    In validation mode (press botton 1 when starting up), most actions generate the events (you can clearly see the prints by connecting with Tera Term or a similar program). you should see many logs of "LPComp High Voltage event". using the LED CLI command is easiest to test this

    I hope this helps you test it, and please let me know if I can provide any more assistance, as it isn't a small project and is kind of messy (we're trying many things with it)

  • You might consider ground bounce or Vdd dip; should the LPCOMP input level be near to the switching threshold, such bounce or dip occurring as a result of a change in applied load to Gnd and Vcc - such as turning an LED on or off - can push the sampled pin (actually maybe not the pin but internal circuit) to the threshold unexpectedly. A simple test is to run the same code and disconnect in turn anything that changes the current, typically the LEDs. If that changes the issue, then solutions involve signal routing, eg supply the LED from the battery but isolate the nRF via a schottcky or ideal diode with a local capacitor, or synchronously suppress the LPCOMP during LED transitions. Posting the circuit would allow more suggestions.

Related