EmbeddedRelated.com
Forums

GPIO read gives wrong value in 17xx

Started by prab...@yahoo.co.in April 13, 2010
So no, you didn’t fix the bug. Duh. Even after I told you? Double duh.

And no, you didn’t post a complete program, did you?

No wonder you’re having problems, you can’t even taken answers given to you on a plate. You can’t take instructions, so I guess reading a manual is just too much effort as well. :-(

-- Paul.

From: l... [mailto:l...] On Behalf Of pra bu
Sent: 15 April 2010 12:24
To: l...
Subject: Re: [lpc2000] Re: GPIO read gives wrong value in 17xx(it needs delay)

Hi ,
here is my code.

#define GPIO0_SET(n) (GPIO0->FIOSET |= (1 << (n)))
#define GPIO0_CLR(n) (GPIO0->FIOCLR |= (1 << (n)))
#define GPIO0_DIR_OUT(n) (GPIO0->FIODIR |= (1 << (n)))
#define GPIO0_MASK(n) (GPIO0->FIOMASK &= ~(1 << (n)))

void testGPIO()
{
/* Have already set 15th bit of PCONP,pinsel regsiter for gpio*/
GPIO0_DIR_OUT(0);
GPIO0_MASK(0);(tested with setting mask and without setting mask.same result)
GPIO0_SET(0);
dbgprintf("Pin 0.0 Set is:%d\n",GPIO0_READ(0)); gives wrong vale
dbgprintf("Pin 0.0 Set is:%d\n",GPIO0_READ(0));gives correct value
}

Same issue when clear gpio.

So, did you fix the bug in your program related to FIOSET and FIOCLR before posting?
Ans : still now i didn't this bug.
Did you account for the write buffer on the CM3?
Ans: not understand
Thanks,

_____

From: Paul Curtis
To: l...
Sent: Thu, 15 April, 2010 4:34:22 PM
Subject: RE: [lpc2000] Re: GPIO read gives wrong value in 17xx(it needs delay)

So, did you fix the bug in your program related to FIOSET and FIOCLR before posting?

Reading the PIN value will return what’s sensed at the pin. Did you account for the write buffer on the CM3?

Questions, I know… And you should post a complete program, not just a fragment.

-- Paul.

From: lpc2000@yahoogroups .com [mailto:lpc2000@ yahoogroups. com] On Behalf Of pra bu
Sent: 15 April 2010 12:01
To: lpc2000@yahoogroups .com
Subject: Re: [lpc2000] Re: GPIO read gives wrong value in 17xx(it needs delay)

Hi all,
Here is my observations.

Test case 1:(With optimization - Os)

Step 1:
I have configured any one GPIO(ex.P0.1) as Output.
Step 2:
Set that GPIO as High.
Step 3:
Read that GPIO and Print the GPIO value using printf().Here GPIO value is 0.This is wrong.
Step 4:
Again read that GPIO and Print the GPIO value using printf().Here GPIO value is 1.This is correct.

Test case 2:(With optimization - O0)

Step 1:
I have configured any one GPIO(ex.P0.1) as Output.
Step 2:
Set that GPIO as High.
Step 3:
Read that GPIO and Print the GPIO value using printf().Here GPIO value is 1.This is correct
Step 4:
Again read that GPIO and Print the GPIO value using printf().Here GPIO value is 1.This also correct.

I have checked assembly code of these test cases.There is no issue
in code generation.

I have also tested same test cases on LPC2364.I couldn't see this Issue.

So This is not compiler related Issue.

Do we need to configure any registers? Is this expected behavior??if so,why we didn't see this issue in LPC2364?

My setup(both 2364 and 1764):

Oscillator clock(Crystal) = 24 MHZ.
PLL0 Output clock = 288 MHZ.
CPU clock = 48 MHZ.
PCLK = 12 MHZ.
PCLKSEL0,1 = 0 ;

FYI:We are using same HW board design for both LPC.One board is with LPC2364 and other
board is with LPC1764.

Thanks,

_____

From: pra bu
To: lpc2000@yahoogroups .com
Sent: Thu, 15 April, 2010 3:26:21 PM
Subject: Re: [lpc2000] Re: GPIO read gives wrong value in 17xx

Maybe there is a problem in the input signal hardware that delays the signal?

We are using same board design for both lpc1764 and lpc2364.Do we need to
change crystal for lpc1764 board ??? or any other thing in board ???

Thanks,

_____

From: alexander_ribero
To: lpc2000@yahoogroups .com
Sent: Wed, 14 April, 2010 11:12:12 PM
Subject: [lpc2000] Re: GPIO read gives wrong value in 17xx

Hi:

I'm using the LPC1752 and I haven't have any trouble reading /setting the GPIO pins:

To read a GPIO pin:

uint32_t GPIO_P0_0_RX_ Read(void)
{
uint32_t result;

// Read current value
if((LPC_GPIO0- >FIOPIN & (1UL << 0)))
{
result = TRUE;
}
else
{
result = FALSE;
}

return (result);
}

To set HIGH pin:

void GPIO_P0.1_High( void)
{
LPC_GPIO0->FIOSET |= (1UL << 1);
}

To set LOW pin:

void GPIO_P0.1_Low( void)
{
LPC_GPIO0->FIOCLR |= (1UL << 1);
}

Maybe there is a problem in the input signal hardware that delays the signal?

Regards,

Alex

--- In lpc2000@yahoogroups .com, pra bu wrote:
>
> hi all,
> after configuring, setting gpios,if i read that pin suddenly means it gives wrong value.Again read means it gives correct value.i think It takes two or more instruction cycle to update pin value in to this register.Anyone facing this issue???any ideas?
>
> Thanks,
> ____________ _________ _________ __
> From: "prabuisin@. .."
> To: lpc2000@yahoogroups .com
> Sent: Tue, 13 April, 2010 1:06:07 PM
> Subject: [lpc2000] GPIO read gives wrong value in 17xx
> hi all,
> Is any one facing following Issue?
>
> I have set some gpios(leds). LEDs are on.But if i read that gpio value means
> it gives value 1.I have set 15th bit of PCONP also.So i am suspecting
> gpio reads(FIOPIN register)??? i am using lpc17xx.h from FreeRTOSdemo code.
>
> any idea about what wrong in this issue???
> Thank
>
> Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger. yahoo.com/ download. php
>
Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger. yahoo.com/ download. php
Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger. yahoo.com/ download. php

Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php

An Engineer's Guide to the LPC2100 Series

Hello

It seems that you don't like reading so I will use a few words only.

SDA
OPEN DRAIN
SLOW RISETIME

Not sure if this is related, read the user-manual and check it.

Aalt
Hi all,
My apologizes.I didn't try with answer given by you.Sorry to say this.
Ok.i will change code and test and update soon.

Thanks,

________________________________
From: Aalt Lokhorst
To: l...
Sent: Thu, 15 April, 2010 5:42:05 PM
Subject: Re: [lpc2000] Re: GPIO read gives wrong value in 17xx(it needs delay)

Hello

It seems that you don't like reading so I will use a few words only.

SDA
OPEN DRAIN
SLOW RISETIME

Not sure if this is related, read the user-manual and check it.

Aalt

Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php
Hi Paul,
here is my updated code.

#define GPIO0_SET(n)
(GPIO0->FIOSET (1 << (n)))
#define GPIO0_CLR(n)
(GPIO0->FIOCLR = (1
<< (n)))
#define GPIO0_DIR_OUT( n)
(GPIO0->FIODIR |= (1 << (n)))
#define
GPIO0_MASK(n)
(GPIO0->FIOMASK &= ~(1 << (n)))
#define GPIO0_READ(n) ((GPIO0->FIOPIN >> (n)) & 0x01)

void testGPIO()
{
/* Have already set 15th bit of PCONP,pinsel regsiter for gpio*/
GPIO0_DIR_OUT( 0);
GPIO0_MASK(0) ;(tested with setting mask and without setting
mask.same result)
GPIO0_SET(0) ;
dbgprintf("Pin 0.0 Set is:%d\n",GPIO0_READ( 0));
gives wrong value
dbgprintf("Pin 0.0 Set
is:%d\n",GPIO0_READ( 0));gives correct value
}

As per my understanding,
I have fixed the bug which u have mentioned( instead of ' |= ' ,used '=' for set,clr gpio register .Is it Ok??
If so,
After fixing this bug,still i am having same Issue.
I have also read that part 6.2 Writing to FIOSET/FIOCLR vs. FIOPIN in user guide.

Thanks,

________________________________
From: Paul Curtis
To: l...
Sent: Thu, 15 April, 2010 5:03:33 PM
Subject: RE: [lpc2000] Re: GPIO read gives wrong value in 17xx(it needs delay)

So no, you didn’t fix the bug. Duh. Even after I told you? Double
duh.

And no, you didn’t post a complete program, did you?

No wonder you’re having problems, you can’t even taken answers
given to you on a plate. You can’t take instructions, so I guess reading a
manual is just too much effort as well. :-(

-- Paul.

From:lpc2000@yahoogroups .com
[mailto:lpc2000@ yahoogroups. com] On Behalf Of pra bu
Sent: 15 April 2010 12:24
To: lpc2000@yahoogroups .com
Subject: Re: [lpc2000] Re: GPIO read gives wrong value in 17xx(it needs
delay)

Hi ,
here is my code.

#define GPIO0_SET(n)
(GPIO0->FIOSET |(1 << (n)))
#define GPIO0_CLR(n)
(GPIO0->FIOCLR |= (1
<< (n)))
#define GPIO0_DIR_OUT( n)
(GPIO0->FIODIR |= (1 << (n)))
#define
GPIO0_MASK(n)
(GPIO0->FIOMASK &= ~(1 << (n)))

void testGPIO()
{
/* Have already set 15th bit of PCONP,pinsel regsiter for gpio*/
GPIO0_DIR_OUT( 0);
GPIO0_MASK(0) ;(tested with setting mask and without setting
mask.same result)
GPIO0_SET(0) ;
dbgprintf("Pin 0.0 Set is:%d\n",GPIO0_READ( 0));
gives wrong vale
dbgprintf("Pin 0.0 Set
is:%d\n",GPIO0_READ( 0));gives correct value
}

Same issue when clear gpio.
So, did you fix
the bug in your program related to FIOSET and FIOCLR before posting?
Ans : still now i didn't this bug.
Did you account for the write buffer on the CM3?
Ans: not understand
Thanks,

________________________________

From:Paul Curtis

To: lpc2000@yahoogroups .com
Sent: Thu, 15 April, 2010 4:34:22 PM
Subject: RE: [lpc2000] Re: GPIO read gives wrong value in 17xx(it needs
delay)

So, did you fix the bug in your program
related to FIOSET and FIOCLR before posting?

Reading the PIN value will return what’s
sensed at the pin. Did you account for the write buffer on the CM3?

Questions, I know… And you should
post a complete program, not just a fragment.

-- Paul.

From:lpc2000@yahoogroups .com [mailto:lpc2000@
yahoogroups. com] On Behalf Of pra bu
Sent: 15 April 2010 12:01
To: lpc2000@yahoogroups .com
Subject: Re: [lpc2000] Re: GPIO read gives wrong value in 17xx(it needs
delay)

Hi
all,
Here is my observations.

Test case 1:(With optimization - Os)

Step 1:
I have configured any one
GPIO(ex.P0.1) as Output.
Step 2:
Set that GPIO as High.
Step 3:
Read that GPIO and Print the
GPIO value using printf().Here GPIO value is 0.This is wrong.
Step 4:
Again read that GPIO and Print the
GPIO value using printf().Here GPIO value is 1.This is correct.

Test case 2:(With optimization - O0)

Step 1:
I have configured any one
GPIO(ex.P0.1) as Output.
Step 2:
Set that GPIO as High.
Step 3:
Read that GPIO and Print the
GPIO value using printf().Here GPIO value is 1.This is correct
Step 4:
Again read that GPIO and Print the
GPIO value using printf().Here GPIO value is 1.This also correct.

I have checked assembly code of these test cases.There is no issue
in code generation.

I have also tested same test cases on LPC2364.I couldn't see this Issue.

So This is not compiler related Issue.

Do we need to configure any registers? Is this expected behavior??if so,why we
didn't see this issue in LPC2364?

My setup(both 2364 and 1764):

Oscillator clock(Crystal) = 24 MHZ.
PLL0
Output clock = 288 MHZ.
CPU
clock
= 48 MHZ.

PCLK
= 12 MHZ.

PCLKSEL0,1
= 0 ;

FYI:We are using same HW board design for both LPC.One board is with LPC2364
and other
board is with LPC1764.

Thanks,

________________________________

From:pra bu

To: lpc2000@yahoogroups .com
Sent: Thu, 15 April, 2010 3:26:21 PM
Subject: Re: [lpc2000] Re: GPIO read gives wrong value in 17xx

Maybe
there is a problem in the input signal hardware that delays the signal?

We are using same board design for both lpc1764 and
lpc2364.Do we need to
change crystal for lpc1764 board ??? or any other thing in board ???

Thanks,

________________________________

From:alexander_ribero
To: lpc2000@yahoogroups .com
Sent: Wed, 14 April, 2010 11:12:12 PM
Subject: [lpc2000] Re: GPIO read gives wrong value in 17xx

Hi:

I'm using the LPC1752 and I haven't have any trouble reading /setting the GPIO
pins:

To read a GPIO pin:

uint32_t GPIO_P0_0_RX_ Read(void)
{
uint32_t result;

// Read current value
if((LPC_GPIO0- >FIOPIN & (1UL << 0)))
{
result = TRUE;
}
else
{
result = FALSE;
}

return (result);
}

To set HIGH pin:

void GPIO_P0.1_High( void)
{
LPC_GPIO0->FIOSET |= (1UL << 1);
}

To set LOW pin:

void GPIO_P0.1_Low( void)
{
LPC_GPIO0->FIOCLR |= (1UL << 1);
}

Maybe there is a problem in the input signal hardware that delays the signal?

Regards,

Alex

--- In lpc2000@yahoogroups
.com, pra bu wrote:
>
> hi all,
> after configuring, setting gpios,if i read that pin suddenly means it
gives wrong value.Again read means it gives correct value.i think It takes two
or more instruction cycle to update pin value in to this register.Anyone facing
this issue???any ideas?
>
> Thanks,
> ____________ _________ _________ __
> From: "prabuisin@. .."
> To: lpc2000@yahoogroups
.com
> Sent: Tue, 13 April, 2010 1:06:07 PM
> Subject: [lpc2000] GPIO read gives wrong value in 17xx
> hi all,
> Is any one facing following Issue?
>
> I have set some gpios(leds). LEDs are on.But if i read that gpio value
means
> it gives value 1.I have set 15th bit of PCONP also.So i am suspecting
> gpio reads(FIOPIN register)??? i am using lpc17xx.h from FreeRTOSdemo
code.
>
> any idea about what wrong in this issue???
> Thank
>
> Send free SMS to your Friends on Mobile from your Yahoo! Messenger.
Download Now! http://messenger.
yahoo.com/ download. php
>

Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download
Now! http://messenger.
yahoo.com/ download. php

Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download
Now! http://messenger.
yahoo.com/ download. php

Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download
Now! http://messenger. yahoo.com/ download. php

Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php