Jump to content
Sign in to follow this  
nyto4

Why is analogRead() so slow?

Recommended Posts

According to the docs, it takes ~100 microseconds: http://energia.nu/AnalogRead.html.

I measured this and it seems to be almost exactly 100 microseconds.

 

Why does it take so long? This limits me to 10kHz sample speed.

 

By the way, how fast have any of you guys sampled on the ADC12 of F5529?

Share this post


Link to post
Share on other sites

100us sound about right: The ADC clock is set to ~1 MHz (MODOSC = ~5MHz / 5). The sample and hold is set to 96 ADC12CLK.

The sample and hold is what takes up most of the time.

 

I think the ADC12 that is in the F5529 is rated at max 200ksps. 

Share this post


Link to post
Share on other sites

Yes, the software does what it is spec'd to do. The question was more why Energia underutilizes the F5529's resources, as it is capable of much more than 10kHz sampling.

 

I went ahead and set the ADC clock to 5MHz and lowered the number of hold cycles. I'm not sure if this follows the spec but I am not reading a high impedance load, so there is no real reason to use a whole 100 usec.

 

For anyone interested, change analogRead() in 'hardware/msp430/cores/msp430/wiring_analog.c'.

Share this post


Link to post
Share on other sites

Probably to be extremely conservative for accuracy's sake. It might be a cool idea to offer a richer API to enhance the utility, but general compatibility with Wiring and particularly Arduino is important.

 

Sent from my Galaxy Note II with Tapatalk 4

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...