NRF54L15-DK : ADC Threshold Event Configuration using LPCOMP and ANADETECT

Hello Nordic Team,

I am currently working with the NRF54L15-DK. I have successfully configured the simple ADC on AIN4 (P1.11) and am able to read the raw sensor values.

Overlay : 

&adc {
	#address-cells = <1>;
	#size-cells = <0>;
	
	channel@4 {
		reg = <4>;
		zephyr,gain = "ADC_GAIN_1"; //"ADC_GAIN_1_4"
		zephyr,reference = "ADC_REF_INTERNAL";
		zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
		zephyr,input-positive = <NRF_SAADC_AIN4>; /* P1.11 */
		zephyr,resolution = <12>;
		//zephyr,oversampling = <2>;
	};
};


However, I would like to understand how to configure and set an ADC threshold using the ANADETECT feature. Specifically, I want to know how to detect when the ADC value crosses a defined threshold, either up , down or cross  and how to receive an event when this occurs. Additionally, I would like guidance on configuring the LPCOMP for this purpose.

Please provide the necessary prj.conf settings, .overlay configuration, and a sample example to help me implement this functionality.

Thanks & Regards,
Pratik Panchal

Parents
  • Hello  

    Thank you for your response.

    I reviewed the Nordic thread you shared and used the referenced code to configure and integrate a comparator into my application. I connected a potentiometer to the defined ADC pin for input variation.

    However, I expected to receive specific up or down events based on the configured threshold up/down values.
    I referred to the overlay file from the provided GitHub repository, but despite defining th_up and th_down values, the test_callback function does not increment the count on defined up or down threshold, but it only increments when we fully increase the potentiometer value to 4092 = 0.899V, and the event 
    bool event = comparator_get_output(test_dev); Returns 1 on 0.899V.

    Even I modified the value of th-up to 40, then also the event returns 1 only at 0.899V.

    Here, my application overlay for the comparator :

    &comp {
    	compatible = "nordic,nrf-comp";
    	main-mode = "SE";
    	psel = "AIN4"; /* P1.11 */
    	refsel = "VDD";
    	sp-mode = "HIGH";
    	th-up = <63>;
    	th-down = <31>;//<59>;
    	isource = "DISABLED";
    	status = "okay";
    };
     

    Could you please provide a sample that demonstrates the detailed usage of the APIs for configuring up/down thresholds and handling the corresponding events?

    Thanks & Regards,
    Pratik Panchal

Reply
  • Hello  

    Thank you for your response.

    I reviewed the Nordic thread you shared and used the referenced code to configure and integrate a comparator into my application. I connected a potentiometer to the defined ADC pin for input variation.

    However, I expected to receive specific up or down events based on the configured threshold up/down values.
    I referred to the overlay file from the provided GitHub repository, but despite defining th_up and th_down values, the test_callback function does not increment the count on defined up or down threshold, but it only increments when we fully increase the potentiometer value to 4092 = 0.899V, and the event 
    bool event = comparator_get_output(test_dev); Returns 1 on 0.899V.

    Even I modified the value of th-up to 40, then also the event returns 1 only at 0.899V.

    Here, my application overlay for the comparator :

    &comp {
    	compatible = "nordic,nrf-comp";
    	main-mode = "SE";
    	psel = "AIN4"; /* P1.11 */
    	refsel = "VDD";
    	sp-mode = "HIGH";
    	th-up = <63>;
    	th-down = <31>;//<59>;
    	isource = "DISABLED";
    	status = "okay";
    };
     

    Could you please provide a sample that demonstrates the detailed usage of the APIs for configuring up/down thresholds and handling the corresponding events?

    Thanks & Regards,
    Pratik Panchal

Children
Related