Hi Jayant,
Have you added the ADC IO package (CYGPKG_IO_ADC) ?
CYGHWR_HAL_STM32_GPIO_IN is only relevant for digital IOs. To read ADC
channels, you must use cyg_io_lookup / cyg_io_read. Have a look at some
of the ADC test applications for AT91 or LPC24xx.
Hope this helps.
Christophe
-----Original Message-----
From: ecos-discuss-owner@xxxxxxxxxxxxxxxxxxx
[mailto:ecos-discuss-owner@xxxxxxxxxxxxxxxxxxx] On Behalf Of jayant
biswas
Sent: 12. april 2011 17:27
To: ecos-discuss@xxxxxxxxxxxxxxxxxxx
Subject: stm3210e eval board adc question
Hello everyone!
I am new to this list and to ecos and the stm32 and am looking for
some help in reading from ADC inputs.
Here is the test program I have used to see if I can read the inputs.
I am able to read the normal input from the user key on the board, but
I am not able to read the analog input. pot_val is always 0. I test my
program by holding on to the user key and changing the potentiometer
position and then hitting reset. Do you have any ideas?
/* this is a simple hello world program */
#include <stdio.h>
#include <cyg/hal/hal_io.h>
#define CYGHWR_POT CYGHWR_HAL_STM32_GPIO(C, 4, IN, ANALOG)
#define CYGHWR_BUT CYGHWR_HAL_STM32_GPIO(G, 8, IN, FLOATING)
int cyg_user_start(void)
{
cyg_int32 pot_val = 10;
cyg_int32 but_val = 10;
printf("Hello, eCos world!\n");
CYGHWR_HAL_STM32_GPIO_SET(CYGHWR_POT);
CYGHWR_HAL_STM32_GPIO_SET(CYGHWR_BUT);
CYGHWR_HAL_STM32_GPIO_IN(CYGHWR_POT, &pot_val);
CYGHWR_HAL_STM32_GPIO_IN(CYGHWR_BUT, &but_val);
printf("Potentiometer value is %d, button value is %d\n", pot_val,
but_val);
while(1);
return 0;
}
I wasn't able to enable the cdl component CYGPKG_IO_ADC_DEVICES in my
ecos config as it wasn't available.
I have an STM3210E Eval board and am using it with an Amontec JTAG
key. I used the default stm3210e template and changed the target to
ROM. I load the program directly to the ROM so I am not using anything
like Redboot.
Thank you in advance for your help!
Jayant
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
[Linux Embedded]
[U-Boot V2]
[Linux Kernel]
[Linux MIPS]
[Linux ARM]
[Linux for the Blind]
[Linux Resources]
[Photo]
[Yosemite]
[ISDN Cause Codes]
[ECOS Home]
[Site Home]