public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] AT91 GPIO read problem
@ 2009-08-18 14:37 Steven Clugston
  2009-08-18 15:02 ` Andrew Lunn
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Clugston @ 2009-08-18 14:37 UTC (permalink / raw)
  To: ecos-discuss

I'm fairly new to AT91 and have been trying to use the platform macros to setup and read some GPIOs on an Olimex AT91SAM7S256 based board.

They provide their board pre-flashed with a demo program (no source) and you can press the micro switches to toggle/activate various board features using the program. The switches are externally pulled up.

With ecos, I can configure any gpio as an output and set it high or low without any problems, but when it comes to reading a pin's value it seems to always return 0 regardless of the logic level on it.

cyg_bool value
HAL_ARM_AT91_GPIO_CFG_DIRECTION(AT91_GPIO_PA29, AT91_PIN_IN);
HAL_ARM_AT91_GPIO_GET(AT91_GPIO_PA29, value);

'value' is always 0. I've tried a couple of different boards in case the first one has been damaged somehow and different pins in case there is a perculiarity with a particular mulifunction pin.

Also:
 cyg_uint32 pdsr;
 HAL_READ_UINT32(AT91_PIO + AT91_PIO_PDSR, pdsr);
The pdsr status register never seems to change its value when the external logic level is changed.
The only example I can find is in the AT91 usb driver on the power pin.

Does anybody familiar with the AT91 have any ideas what school boy type error I might be making?

Thanks,

Steven

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [ECOS] AT91 GPIO read problem
  2009-08-18 14:37 [ECOS] AT91 GPIO read problem Steven Clugston
@ 2009-08-18 15:02 ` Andrew Lunn
  2009-08-19  7:58   ` Steven Clugston
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Lunn @ 2009-08-18 15:02 UTC (permalink / raw)
  To: Steven Clugston; +Cc: ecos-discuss

On Tue, Aug 18, 2009 at 03:36:53PM +0100, Steven Clugston wrote:
> I'm fairly new to AT91 and have been trying to use the platform macros to setup and read some GPIOs on an Olimex AT91SAM7S256 based board.
> 
> They provide their board pre-flashed with a demo program (no source) and you can press the micro switches to toggle/activate various board features using the program. The switches are externally pulled up.
> 
> With ecos, I can configure any gpio as an output and set it high or low without any problems, but when it comes to reading a pin's value it seems to always return 0 regardless of the logic level on it.
> 
> cyg_bool value
> HAL_ARM_AT91_GPIO_CFG_DIRECTION(AT91_GPIO_PA29, AT91_PIN_IN);
> HAL_ARM_AT91_GPIO_GET(AT91_GPIO_PA29, value);
> 
> 'value' is always 0. I've tried a couple of different boards in case the first one has been damaged somehow and different pins in case there is a perculiarity with a particular mulifunction pin.
> 
> Also:
>  cyg_uint32 pdsr;
>  HAL_READ_UINT32(AT91_PIO + AT91_PIO_PDSR, pdsr);
> The pdsr status register never seems to change its value when the external logic level is changed.
> The only example I can find is in the AT91 usb driver on the power pin.
> 
> Does anybody familiar with the AT91 have any ideas what school boy type error I might be making?

Did you enable the clock to the GPIO subsystem? Output works without a
clock, input does not. Look in i think the power management section of
the manual.

       Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [ECOS] AT91 GPIO read problem
  2009-08-18 15:02 ` Andrew Lunn
@ 2009-08-19  7:58   ` Steven Clugston
  0 siblings, 0 replies; 3+ messages in thread
From: Steven Clugston @ 2009-08-19  7:58 UTC (permalink / raw)
  To: ecos-discuss


>> With ecos, I can configure any gpio as an output and set it high or low without any problems, but when it comes to reading a pin's value it seems to always return 0 regardless of the logic level on it.

>> cyg_bool value
>> HAL_ARM_AT91_GPIO_CFG_DIRECTION(AT91_GPIO_PA29, AT91_PIN_IN);
>> HAL_ARM_AT91_GPIO_GET(AT91_GPIO_PA29, value);

>> 'value' is always 0. I've tried a couple of different boards in case the first one has been damaged somehow and different pins in case there is a perculiarity with a particular mulifunction pin.
>> Does anybody familiar with the AT91 have any ideas what school boy type error I might be making?

> Did you enable the clock to the GPIO subsystem? Output works without a
> clock, input does not. Look in i think the power management section of
> the manual.

>       Andrew

No, I didn't even know there was a GPIO subsystem that needs a clock, but now I know that fixed it:

HAL_WRITE_UINT32 (AT91_PMC + AT91_PMC_PCER, AT91_PMC_PCER_PIOA);

Thanks Andrew, there is only brief mention of it in the 757 page AT91SAM7 manual, so it might have taken me awhile to chance upon it.

Regards,

Steven


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-08-19  7:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-18 14:37 [ECOS] AT91 GPIO read problem Steven Clugston
2009-08-18 15:02 ` Andrew Lunn
2009-08-19  7:58   ` Steven Clugston

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).