I am using the GPIO pins to detect when a sensor is connected. It works, but it takes a long time before the interrupt triggers. Any thoughts on what might be causing this?
So the question is what is the execution cycle time of your while loop. As implied with my question before - a real external IRQ input - the listed once - can improve the speed and detect immediately the disconnect. Or you use a regular timer IRQ to check and flag this.
How do you connect the sensor to the GPIO? Is there a large capacitor somehow involved which needs to be charged up?
I connect the sensor to the gpio through a 1K resistor in series with the pin. I also have a 10K pull down attached to this pin.
Can you provide a simple schematic and more details about the sensor?
Attached is a drawing. I have 4 of these circuits connection to P1.2, P1.3,P0.5, and P0.6.
OK, but essential is the output impedance from the sensor you use. What is this?
There isn't a significant impedence. The sensor is a resistive bridge. The 2.5V is is jumpered directly to the input from the power rail when the connector is plugged into the receptacle.
OK, from the HW point of view I do not understand, why this inputs are not pulled high fast enough. But the question is now according to your pin's listed and used, how do you trigger a interrupt. External IRQ-inputs are only available on P0.4, P1.0, P2.0 and P2.1. So it looks like your SW is somehow causing the delay!?
That is where I am at. Essentially we execute a while loop when we initialize the program. So what we are doing is reading the value of the registers that hold the input status with each iteration of the loop. I don't believe we have a circuit issue, but I needed to confirm that I'm no using the input incorrectly. Can you suggest a better way to monitor the status of the inputs? We know from our scope readings that the voltage drops immediately when the sensor plug is disconnected.
Ok. I am going to try the time irq. I don't know what the cycle time is. We are monitoring one input on adc0 and 4 channels on adc1 and listening for rs232 messages during each cycle so it might be longer than we think.
I presume that the original question is misleading - “a long time before the interrupt triggers” – as it is not actually connected to an IRQ and the delay is associated with the polling in your loop.
MMAs suggestion to use a timre, or to check it more frequently in the loop should solve the problem for you.
Has this been resolved for you?
That's true. Initially I thought he was checking interrupts. We have resolved the issue. I haven't taken a hard look at what he is doing now, but the was an issue in the order we were doing things in our program. It had something to do with disabling interrupts while we were processing ADC data.
Retrieving data ...