public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: jayant biswas <biswasj@gmail.com>
To: Christophe Coutand <ccoutand@stmi.com>
Cc: ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] stm3210e eval board adc question
Date: Wed, 13 Apr 2011 08:48:00 -0000	[thread overview]
Message-ID: <BANLkTi=4NaL4LaOnHavfqV+zKyUPPwaK8Q@mail.gmail.com> (raw)
In-Reply-To: <D6050C555CC56940A7AF32652283027603DAC1CA@mail2.STMIRV01.COM>

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 = 0;
  cyg_io_handle_t handle;

  res = cyg_io_lookup("/dev/adc00", &handle);
  if(res != ENOERR) {
	  printf("Error in cyg_io_lookup %d\n", res);
  }

  cyg_int32 sample = 0;
  cyg_uint32 len = sizeof(sample);

  res = cyg_io_read(handle, &sample, &len);
  if(res != 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 <ccoutand@stmi.com> 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 <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

  reply	other threads:[~2011-04-13  8:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-12 15:27 jayant biswas
2011-04-12 16:22 ` Christophe Coutand
2011-04-13  8:48   ` jayant biswas [this message]
     [not found]     ` <D6050C555CC56940A7AF3265228302761394EC@mail2.STMIRV01.COM>
2011-04-13 12:38       ` jayant biswas
2011-04-13 18:11         ` [ECOS] " John Dallaway
2011-04-18  8:48           ` jayant biswas
2011-04-18  9:49             ` [ECOS] " Christophe Coutand
2011-04-18 14:49               ` [ECOS] " jayant biswas
2011-04-19  7:27                 ` [ECOS] " Christophe Coutand
2011-04-19 12:43                   ` [ECOS] " jayant biswas
2011-05-02 10:16                     ` jayant biswas
2011-05-02 21:45                       ` [ECOS] " Christophe Coutand
2011-05-03  7:58                         ` [ECOS] " jayant biswas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='BANLkTi=4NaL4LaOnHavfqV+zKyUPPwaK8Q@mail.gmail.com' \
    --to=biswasj@gmail.com \
    --cc=ccoutand@stmi.com \
    --cc=ecos-discuss@ecos.sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).