Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > repeated readings

Reply
Thread Tools

repeated readings

 
 
Lowell
Guest
Posts: n/a
 
      01-22-2007
Hello,
i need to read from a variable every 'x' microseconds. Someone can help
me?

Thanks!



 
Reply With Quote
 
 
 
 
Ben Pfaff
Guest
Posts: n/a
 
      01-22-2007
"Lowell" <(E-Mail Removed)> 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[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\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[i]\
);}return 0;}
 
Reply With Quote
 
 
 
 
santosh
Guest
Posts: n/a
 
      01-22-2007
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.

 
Reply With Quote
 
Lowell
Guest
Posts: n/a
 
      01-22-2007

"Ben Pfaff" <(E-Mail Removed)> ha scritto nel messaggio
news:(E-Mail Removed)...
> "Lowell" <(E-Mail Removed)> 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[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
> \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[i]\
> );}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...


 
Reply With Quote
 
Flash Gordon
Guest
Posts: n/a
 
      01-22-2007
Lowell wrote, On 22/01/07 18:56:
> "Ben Pfaff" <(E-Mail Removed)> ha scritto nel messaggio
> news:(E-Mail Removed)...
>> "Lowell" <(E-Mail Removed)> 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[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
>> \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[i]\
>> );}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
 
Reply With Quote
 
Raman
Guest
Posts: n/a
 
      01-23-2007

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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Histogram readings.. the_niner_nation Digital Photography 6 05-18-2007 09:39 AM
Computer Temp. Readings Dardamar Computer Support 3 06-20-2005 07:22 AM
Incident readings with a digital camera John Digital Photography 5 11-01-2004 10:47 PM
Readings style sheets. ashish ASP .Net 1 06-01-2004 04:37 PM
new art, digital photos, flash movies, poems, live readings andrew lovatt Digital Photography 0 11-25-2003 02:07 AM



Advertisments