This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: AT91 GPIO read problem
- From: Andrew Lunn <andrew at lunn dot ch>
- To: Steven Clugston <steven dot clugston at newcastle dot ac dot uk>
- Cc: "ecos-discuss at ecos dot sourceware dot org" <ecos-discuss at ecos dot sourceware dot org>
- Date: Tue, 18 Aug 2009 17:02:03 +0200
- Subject: Re: [ECOS] AT91 GPIO read problem
- References: <4DCF6DBD3535F742BB167C528BBEE98038276606C4@EXSAN01.campus.ncl.ac.uk>
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