I am a newbie to microcontrollers and starting with a breakout board(Blueboard). I am facing a logic level problem.
I have a simple program which sets GPIO pins to HIGH and then LOW. I measured the voltage during HIGH setting and it is 3.3 V and when LOW is set it is 0. I am expecting a value of 2.7-2.9V when HIGH and 0.2-0.4V when LOW.
Another interesting point is the high logic level voltage measures 3.3V only if the GPIO direction is output. Otherwise (if direction is input) it measures as 2.2V.
There is nothing connected to the GPIO pins.
#define PINSEL2 (*((volatile unsigned long *) 0x4002C008))
#define PINSEL3 (*((volatile unsigned long *) 0x4002C00C))
#define PINMODE2 (*((volatile unsigned long *) 0x4002C048))
#define PINMODE3 (*((volatile unsigned long *) 0x4002C04C))
#define FIO1DIR (*((volatile unsigned long *) 0x2009C020))
#define FIO1MASK (*((volatile unsigned long *) 0x2009C030))
#define FIO1PIN (*((volatile unsigned long *) 0x2009C034))
#define FIO1SET (*((volatile unsigned long *) 0x2009C038))
#define FIO1CLR (*((volatile unsigned long *) 0x2009C03c))
int main (void)
{
PINSEL2 = 0;
PINSEL3 = 0;
PINMODE2 = 0xAAAAAAAA; /*neither pull-up nor pull-down.*/
PINMODE3 = 0xAAAAAAAA; /*neither pull-up nor pull-down.*/
PINMODE_OD1 = 0;
FIO1DIR = ~0; //all are output
FIO1MASK = 0;
FIO1PIN = ~0; //high
while(1) {
FIO1PIN = ~FIO1PIN;
delay(10000);
}
}
Could it be hardware problem? Or am I missing something?
samueldotj:
I have a simple program which sets GPIO pins to HIGH and then LOW. I measured the voltage during HIGH setting and it is 3.3 V and when LOW is set it is 0. I am expecting a value of 2.7-2.9V when HIGH and 0.2-0.4V when LOW.
Why would you expect that? According to the NXP data sheet for the LPC1768, GPIO low is 0v and high is 3.3v (Vdd). I think you’re confusing the max permitted voltage for a low and the min permitted value for a high output with what the typical values are (0v and Vdd).
Another interesting point is the high logic level voltage measures 3.3V only if the GPIO direction is output. Otherwise (if direction is input) it measures as 2.2V.
There is nothing connected to the GPIO pins.
When the direction is set to input, the pin is floating and you might measure just about any voltage on it from 0v up to Vdd (3.3v). If you want it to be high (3.3v) or low (0v) when an input, then enable pullup or pulldown.
OP, it will help if you think of a digital output as a fairly low value resistor that can be switched to either Vcc (3.3V in your case) or GND (0V). With almost no current flowing through that resistor (your DMM is very high impedance), there is no voltage drop across the resistor, so you read 3.3V or 0V. But when the output is sourcing or sinking significant current (significant relative to its max specs), some voltage will be dropped across the resistor so the high voltage will drop below 3.3V and the low voltage will rise above 0V.
The “resistor”, BTW, is usually the upper or lower transistor of a CMOS output stage.
And when the pin is configured as an input, as was noted, it could float to just about any value. That’s why you should never leave inputs unconnected.