2015-09-23 at 9:36 AM #4811
I’m trying to make a simple application, where if the board detects a signal on one of the BLADE inputs, it turns the light on. My code looks like this:
if(AT91C_BASE_PIOA->PIO_PDSR & RX_PIN) //RX_PIN corresponds to PA11 LedOn(GREEN1); else LedOff(GREEN1);
(code may vary; I don’t have the code in front of me right now, just what I remember)
This is what’s actually happening:
- Default behavior: light is on (it shouldn’t be)
- Touch the RX pin with any conductive material (like pencil graphite): light begins to flicker
- Release the conductive material: light briefly turns off, then turns back on again
I’m wondering if my code is wrong, or if there’s any physical problems, like poor contacts or soldering.
2015-09-24 at 9:23 AM #4843
Like with all debugging problems I cannot know for sure what your issue is without seeing the whole system you have set up but I can take a few best estimates.
First I am guessing the pin on the blade connector is floating (not tied to a ground or driven high)? This is a third state (neither one or zero) and for most chips, a pins response is unknown to floating inputs. Often it is interpreted as a hi signal but it is hard to know. The same uncertainty would occur when contacting the pin with a conductive material as stray charge may be transferred and the grounded state of, say your hand, is unknown.
You should be able to configure the pin with a pull down or pull up resistor so that floating inputs get recognized as lo or hi respectively.
Secondly, I am assuming you are adding to a previously created project. Did you configure the initialization state so that the LED is off at startup? Lastly is this statement in an interrupt or are you polling the pin continuously? If you are polling, what frequency are you polling it at? All of these factors would affect the behavior.
I hope that helps. Please post your solution when you figure it out as it makes for a nice reference example for other students.
- This reply was modified 2 years, 9 months ago by Cameron Smith.
2015-10-02 at 1:04 PM #4933
Thank you very much for your post! Yeah, I forgot that pins can float, which is why my board was behaving strangely. I’ll have to come up with a solution for that, but a pull-down resistor is probably going to be the best option.
You must be logged in to reply to this topic.