From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30802 invoked by alias); 13 Apr 2011 08:48:34 -0000 Received: (qmail 30791 invoked by uid 22791); 13 Apr 2011 08:48:33 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-bw0-f49.google.com (HELO mail-bw0-f49.google.com) (209.85.214.49) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 13 Apr 2011 08:48:24 +0000 Received: by bwz1 with SMTP id 1so489910bwz.36 for ; Wed, 13 Apr 2011 01:48:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.151.202 with SMTP id d10mr426868bkw.168.1302684502376; Wed, 13 Apr 2011 01:48:22 -0700 (PDT) Received: by 10.204.48.135 with HTTP; Wed, 13 Apr 2011 01:48:22 -0700 (PDT) In-Reply-To: References: Date: Wed, 13 Apr 2011 08:48:00 -0000 Message-ID: From: jayant biswas To: Christophe Coutand Cc: ecos-discuss@ecos.sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Subject: Re: [ECOS] stm3210e eval board adc question X-SW-Source: 2011-04/txt/msg00041.txt.bz2 Thank you Christophe for your reply. So I added the ADC IO package as per your suggestion and I enabled the CYGPKG_IO_ADC_DEVICES option. Then I have modified my program as follows: int res =3D 0; cyg_io_handle_t handle; res =3D cyg_io_lookup("/dev/adc00", &handle); if(res !=3D ENOERR) { printf("Error in cyg_io_lookup %d\n", res); } cyg_int32 sample =3D 0; cyg_uint32 len =3D sizeof(sample); res =3D cyg_io_read(handle, &sample, &len); if(res !=3D ENOERR) { printf("Error in cyg_io_read %x\n", res); } printf("ADC value: 0x%x\n", sample); But cyg_io_lookup returns an error of -2. I am not sure if I need to add the packages mentioned here http://www.mail-archive.com/ecos-patches@ecos.sourceware.org/msg01672.html . But I am not able to find these packages among the available ones. Please let me know if I am missing something. Best regards, Jayant On Tue, Apr 12, 2011 at 18:19, Christophe Coutand wrote: > 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@ecos.sourceware.org > [mailto:ecos-discuss-owner@ecos.sourceware.org] On Behalf Of jayant > biswas > Sent: 12. april 2011 17:27 > To: ecos-discuss@ecos.sourceware.org > Subject: [ECOS] 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 > #include > > #define CYGHWR_POT =A0 =A0 =A0CYGHWR_HAL_STM32_GPIO(C, 4, IN, ANALOG) > #define CYGHWR_BUT =A0 =A0 =A0CYGHWR_HAL_STM32_GPIO(G, 8, IN, FLOATING) > > int cyg_user_start(void) > { > =A0cyg_int32 pot_val =3D 10; > =A0cyg_int32 but_val =3D 10; > > =A0printf("Hello, eCos world!\n"); > =A0CYGHWR_HAL_STM32_GPIO_SET(CYGHWR_POT); > =A0CYGHWR_HAL_STM32_GPIO_SET(CYGHWR_BUT); > > =A0CYGHWR_HAL_STM32_GPIO_IN(CYGHWR_POT, &pot_val); > =A0CYGHWR_HAL_STM32_GPIO_IN(CYGHWR_BUT, &but_val); > > =A0printf("Potentiometer value is %d, button value is %d\n", pot_val, > but_val); > =A0while(1); > =A0return 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