Dear Cypress Developer Community,
I am trying to do a simple application using the PSoC 6 BLE Pionner Kit (CY8CKIT-062-BLE) & PSoC Creator 4.3 (+ CyDWR) in which a distance sensor should trigger an interrupt when the value read is above a certain value, meaning the distance sensor is measuring a very short distance, let´s say, for example, 3 cm.
The distance sensor is working fine, I can read the value that it returns in volts and I can turn it into distance.
Unfortunately, I am not capable of correctly setting the interrupt limits and I am not sure how to do it. I found plenty of examples about interrupts, but none with this specific one. I am also following the instructions and information on the SAR ADC Component Datasheet and AN217666, but without success.
As soon as the debugger passes the NVIC_EnableIRQ line, the code jumps into the ISR_1_handler() function regardless of the position of the distance sensor or anything else, as the line Cy_SAR_GetResults16() comes later. In the ISR_1_handler() function, at the moment, I just blink a LED (and call the NVIC_ClearPendingIRW), so I guess it is just the setting of the ADC that it is wrong.
I also tried different “compare modes” and “low” and “high” values and checked the register values in ADC.h, but nothing seems to change. Sorry if the question seems too obvious, but any ideas on what could be wrong in here? Any example/sample code or description available?
Attached are pictures showing the CyDWR setting of the ADC, that I would expect to trigger the interrupt if the value read is above 1.65 V and some lines of code.