repeated readings

Discussion in 'C Programming' started by Lowell, Jan 22, 2007.

  1. Lowell

    Lowell Guest

    Hello,
    i need to read from a variable every 'x' microseconds. Someone can help
    me?

    Thanks!
     
    Lowell, Jan 22, 2007
    #1
    1. Advertising

  2. Lowell

    Ben Pfaff Guest

    "Lowell" <> writes:

    > i need to read from a variable every 'x' microseconds. Someone can help
    > me?


    Maybe you could explain what difficulty you're having. But I
    should warn you, first, that the standard C language and library
    don't provide much support for this kind of thing. You're likely
    to need to resort to implementation-specific constructs, which
    are more likely to be handled well by a newsgroup specific to
    your implementation than by comp.lang.c.
    --
    int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.\
    \n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
    );while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p\
    );}return 0;}
     
    Ben Pfaff, Jan 22, 2007
    #2
    1. Advertising

  3. Lowell

    santosh Guest

    Lowell wrote:
    > Hello,
    > i need to read from a variable every 'x' microseconds. Someone can help
    > me?
    >
    > Thanks!


    If you're developing under POSIX use the nanosleep() function. For
    further details, since pure ISO C, the topic of this group, has no
    reliable method for pausing program execution for microseconds,
    followup in comp.unix.programmer.
     
    santosh, Jan 22, 2007
    #3
  4. Lowell

    Lowell Guest

    "Ben Pfaff" <> ha scritto nel messaggio
    news:...
    > "Lowell" <> writes:
    >
    >> i need to read from a variable every 'x' microseconds. Someone can
    >> help
    >> me?

    >
    > Maybe you could explain what difficulty you're having. But I
    > should warn you, first, that the standard C language and library
    > don't provide much support for this kind of thing. You're likely
    > to need to resort to implementation-specific constructs, which
    > are more likely to be handled well by a newsgroup specific to
    > your implementation than by comp.lang.c.
    > --
    > int main(void){char
    > p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.\
    > \n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int
    > putchar(\
    > );while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof
    > p-1;putchar(p\
    > );}return 0;}



    I use a DSP (ADSP 2181) and i must read from data bus and put the data into
    array every 'x' microseconds. I believed that ansi C supported this
    function...
    Thanks however...
     
    Lowell, Jan 22, 2007
    #4
  5. Lowell

    Flash Gordon Guest

    Lowell wrote, On 22/01/07 18:56:
    > "Ben Pfaff" <> ha scritto nel messaggio
    > news:...
    >> "Lowell" <> writes:
    >>
    >>> i need to read from a variable every 'x' microseconds. Someone can
    >>> help
    >>> me?

    >> Maybe you could explain what difficulty you're having. But I
    >> should warn you, first, that the standard C language and library
    >> don't provide much support for this kind of thing. You're likely
    >> to need to resort to implementation-specific constructs, which
    >> are more likely to be handled well by a newsgroup specific to
    >> your implementation than by comp.lang.c.
    >> --
    >> int main(void){char
    >> p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.\
    >> \n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int
    >> putchar(\
    >> );while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof
    >> p-1;putchar(p\
    >> );}return 0;}


    Please don't quote people signatures (the bit after the "-- ") unless
    you are commenting on them.

    > I use a DSP (ADSP 2181) and i must read from data bus and put the data into
    > array every 'x' microseconds. I believed that ansi C supported this
    > function...
    > Thanks however...


    You believe wrong.

    The C standards say that the implementation defines what you get when
    casting an integer to a pointer, and this will probably get you part way
    there if your "data bus" is mapped in to part of the address space you
    can read. The volatile qualifier will also probably be needed, although
    again the standards leave a significant amount about this implementation
    defined. On the other hand, the standard will not help you at all with
    the "every 'x' microseconds" bit of your problem.

    You would probably be better off asking somewhere like
    comp.arch.embedded, although if you don't show any sign of having made
    some attempt and don't say what part you are having difficulty with I'm
    not sure how helpful they will be.
    --
    Flash Gordon
     
    Flash Gordon, Jan 22, 2007
    #5
  6. Lowell

    Raman Guest

    Lowell wrote:
    > Hello,
    > i need to read from a variable every 'x' microseconds. Someone can help
    > me?
    >
    > Thanks!

    I think you can use signals...But, at the same time I will caution you
    that It is not safe to use signals always.So it depends on your problem
    you want to solve.

    Regards,
    Raman Chalotra
     
    Raman, Jan 23, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Walter

    Repeated Headers in a Repeater

    Robert Walter, Apr 26, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,033
    srinivas091
    Oct 7, 2013
  2. ashish

    Readings style sheets.

    ashish, Jun 1, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    318
    Eliyahu Goldin
    Jun 1, 2004
  3. John

    Recommened readings?

    John, Dec 7, 2004, in forum: Ruby
    Replies:
    8
    Views:
    101
    Nicholas Van Weerdenburg
    Dec 8, 2004
  4. Replies:
    1
    Views:
    91
    Mike G.
    Jun 1, 2007
  5. Ney André de Mello Zunino

    Counter-intuitive io vs no-io time readings

    Ney André de Mello Zunino, Apr 9, 2014, in forum: C++
    Replies:
    6
    Views:
    100
    Ney André de Mello Zunino
    Apr 10, 2014
Loading...

Share This Page