Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

brianmakabro

Member Since 02 Mar 2015
Offline Last Active Apr 27 2015 02:31 PM
-----

#61992 Interrupt Port and Debouncing

Posted by brianmakabro on 30 March 2015 - 10:26 PM

From 

https://msdn.microso...y/cc532335.aspx

 

"When configuring an interrupt port, note the differences between level and nonlevel interrupts. Level interrupts, which are either InterruptEdgeLevelHigh or InterruptEdgeLevelLow interrupts, are dispatched when the value on a pin matches the specified high value or low value, respectively. The system dispatches only the first occurrence of a level interrupt until it is cleared by means of the ClearInterrupt method. With nonlevel interrupts, every specified edge is dispatched, and the ClearInterrupt method throws anInvalidOperationException.

In practice, it is best to use level interrupts when the interrupt condition needs to be checked only periodically."

 

Based on the above explanation, your interrupt will ONLY fire when the edge is high, so checking for both high and low states in the interrupt event is not necessary.  I would also think that heartbeatInput.ClearInterrupt() should be called unconditionally from the interrupt event handler itself, before it exits the handler, (since your "handleHeartBeat()" will only be called from time to time.)  

On first look of your code, the ClearInterrupt will not always be fired - it will only be called if ts.Ticks > 1500000.

 

Also - you might try using the GlitchFilter to de-bounce.... I believe that's one of the things it is supposed to be used for.

 

Brian M.




#61835 Inconsistent Server Response

Posted by brianmakabro on 10 March 2015 - 06:25 PM

Maybe some latency in the network is causing your int bytesReceived = clientSocket.Available; statement to continue looping, whereas putting a breakpoint there gives the client socket enough time to have processed the request... 

 

Maybe something like:

 

while (clientSocket.Available == 0) { // waiting for request to be processed };

 

would allow the request to get fully queued up before the code continues?




home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.