| Author |
Message |
|
|
Posted: Jan 10, 2012 - 12:52 PM |
|

Joined: Jul 17, 2010
Posts: 97
|
|
hi,
i am reading from a gpio, my controller is operating at 5V. should not it treat 2.2volts as logic 0?
it treats 2.2 volts as logic high..
is this behavior normal or is there any issue in my controller? |
|
|
| |
|
|
|
|
|
Posted: Jan 10, 2012 - 01:01 PM |
|


Joined: May 04, 2007
Posts: 3529
Location: Geelong Australia, Home of the "Cats"
|
|
|
Quote:
is this behavior normal or is there any issue in my controller?
Yes & no.
From AVR data sheet, Vil (Voltage input low) is specified as 0.3*Vcc. So, for you to have an logical 0, the input must be <=1.5V |
_________________ Charles Darwin, Lord Kelvin & Murphy are always lurking about!
Lee -.-
(If you haven't already done so, edit your PostNuke profile and let let us know where you are, what you do & what your interests are.)
|
| |
|
|
|
|
|
Posted: Jan 10, 2012 - 01:03 PM |
|

Joined: May 24, 2004
Posts: 5996
Location: Tampere, Finland
|
|
|
bilal_fakhar wrote:
hi,
i am reading from a gpio, my controller is operating at 5V. should not it treat 2.2volts as logic 0?
it treats 2.2 volts as logic high..
is this behavior normal or is there any issue in my controller?
The datasheet may have graphs to show the levels or just minimum and maximum voltages as numbers. Depends on the microcontroller. Some AVRs have logic low maximum at 0.2*VCC and minimum logic high as 0.6*VCC, so it means everything above 1V and below 3V means undefined.
Some microcontrollers are TTL compatible, which means voltages over 2.0 are high and voltages below 0.8 are low. So based on that, I do not understand why you think 2.2 should read as low, to me that would read high, but only if datasheet says so. |
Last edited by Jepael on Jan 10, 2012 - 01:06 PM; edited 1 time in total
|
| |
|
|
|
|
|
Posted: Jan 10, 2012 - 01:04 PM |
|

Joined: Jul 17, 2010
Posts: 97
|
|
|
|
|
|
|
Posted: Jan 10, 2012 - 01:05 PM |
|


Joined: Jan 08, 2009
Posts: 1153
Location: Lund, Sweden
|
|
Only you know which controller you have. Check the datasheet for that controller.
But if it's an AVR that can be operated at 5V it will probably say (for mega48-family@5V):
V_il_max = 0.3*Vcc = 1.5V in your case
V_ih_min = 0.6*Vcc = 3V
so with 2.2V it can be interpreted either as low or high without being out of specification. |
|
|
| |
|
|
|
|
|
Posted: Jan 10, 2012 - 01:08 PM |
|

Joined: Jul 17, 2010
Posts: 97
|
|
|
|
|
|
|
Posted: Jan 10, 2012 - 01:09 PM |
|


Joined: May 04, 2007
Posts: 3529
Location: Geelong Australia, Home of the "Cats"
|
|
|
Quote:
so with 2.2V it can be interpreted either as low or high without being out of specification.
Incorrect, the level of 2.2V is not defined and clearly out of spec! |
_________________ Charles Darwin, Lord Kelvin & Murphy are always lurking about!
Lee -.-
(If you haven't already done so, edit your PostNuke profile and let let us know where you are, what you do & what your interests are.)
|
| |
|
|
|
|
|
Posted: Jan 10, 2012 - 01:24 PM |
|


Joined: Jan 08, 2009
Posts: 1153
Location: Lund, Sweden
|
|
Well that's what I meant, but the other way around.
If you apply 2.2V it's a valid voltage on a input pin (between (-0.5V and Vcc+0.5V), therefore it's within specification. But it's not within specification for either high or low level, therefor it can be treated as either high or low by the MCU. (Or will you receive neither 0 or 1 if reading the PINx ) |
|
|
| |
|
|
|
|
|
Posted: Jan 10, 2012 - 02:02 PM |
|


Joined: Feb 19, 2001
Posts: 25912
Location: Wisconsin USA
|
|
|
Quote:
Incorrect, the level of 2.2V is not defined and clearly out of spec!
No, that statement is incorrect.
Given the earlier numbers, the datasheet guarantees that any level below 1.5V will read as a logic low. Any level above 3.0V will read as a logic high.
The values in between could read either way.
Lee, what value other than 1/0 would you expect the pin to read?
IME I had a Mega88 5V app that tripped going high at 2.3V, regularly and repeatedly. We used that fact to eliminate an analog comparator "reference" voltage.
To OP and Lee: What does it matter what the "trip" voltage is? I suppose one could have a voltage divider for e.g. power loss or overheating or whatever. But IME the trip level is consistent. The modern datasheets, as mentioned, have some graphs on typical behaviour and hysteresis. |
|
|
| |
|
|
|
|
|
Posted: Jan 10, 2012 - 03:16 PM |
|


Joined: Sep 06, 2007
Posts: 129
|
|
| Wonder if OP just needs to be introduced to the weird and wonderful world of pull-ups or pull-downs? Letting things float is never wise and if it's actually driven to 2.2V then why not simply arrange to drive it to 1.5 or less instead? |
|
|
| |
|
|
|
|
|
Posted: Jan 10, 2012 - 08:12 PM |
|


Joined: May 04, 2007
Posts: 3529
Location: Geelong Australia, Home of the "Cats"
|
|
The OP needs to tell us what he/she is actually attempting to do!
Quote:
so with 2.2V it can be interpreted either as low or high without being out of specification.
&
Quote:
Incorrect, the level of 2.2V is not defined and clearly out of spec!
&
Quote:
Given the earlier numbers, the datasheet guarantees that any level below 1.5V will read as a logic low. Any level above 3.0V will read as a logic high.
Correct, it was late at night for me and I did not word it well.
How about-
Whilst electrically within spec, the logical state is indeterminate. a condition to be avoided! Either the inputs weak internal pull-up should be enabled or a stronger (typ 10K) external pull-up used.
One point worth making to the OP is that a multimeter is not a great logic test tool. The voltage read needs to be translated to a logic (or possibly invalid) condition.
Using a logic probe this happens automatically hiving either a LO,a HI or neither. Who really cares what the voltage is then, and you can do it out of the corner of your eye.  |
_________________ Charles Darwin, Lord Kelvin & Murphy are always lurking about!
Lee -.-
(If you haven't already done so, edit your PostNuke profile and let let us know where you are, what you do & what your interests are.)
|
| |
|
|
|
|
|
Posted: Jan 10, 2012 - 08:36 PM |
|


Joined: Feb 19, 2001
Posts: 25912
Location: Wisconsin USA
|
|
|
Quote:
Either the inputs weak internal pull-up should be enabled or a stronger (typ 10K) external pull-up used.
But--THAT depends on
Quote:
The OP needs to tell us what he/she is actually attempting to do!
And OP is strangely quiet on that. We don't know if it is a true floating-pin situation.
As I said, I used logic "trip" to eliminate an analog comparator reference.
With a bit of filtering and a voltage divider, a logic-level "trip" could be used with a thermistor for "overtemp" detection. Or, say, undervoltage/loss of power.
In the cases above the level can be "calibrated" with a pot or resistor value choice. |
|
|
| |
|
|
|
|
|