[ECOS] AT91 GPIO read problem

Andrew Lunn andrew@lunn.ch
Tue Aug 18 15:02:00 GMT 2009


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



More information about the Ecos-discuss mailing list