cli() and sei() delay needed?

Why have you sleep() in your code ? I suggest you take that out until everything else works.

Is 2000 msecs the shortest delay that works ?
If not I suggest you find out what is the minimum - that may be useful diagnostic info.

if (sample < 1024) // toss out spurious readings

How can you have readings that exceed 1024 ?

I don't know anything about the DAC you are using but it would seem totally pointless if it takes more than a few µsecs to work

Rather than have a WHILE that depends on millis() within loop() I would dispense with the WHILE and use loop() itself for the iteration.

...R

Hi,

I think its time for.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Can you please post a complete copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

What is your application, we need to know what you are expecting from you project.

Tom..... :slight_smile:

The program I posted is a reduced version of my actual code, so I'm considering it to be a test program that isolates the problem. Once this code works, then I can incorporate it into my overall program. That's probably why it doesn't make sense as an application by itself.

I have taken the sleep out, and it still doesn't give me the result I want (DAC output is 0V until a few seconds later, after many iterations create that delay). I tried a delay of 1.5 seconds, and it didn't work. As for the line if (sample < 1024) // toss out spurious readings, I know it doesn't seem necessary and I'm not sure why it was in the sample code I got from a company.

Thanks for the suggestions, I was just wondering if anyone had any similar issue or had insight into this particular problem. I'll just stare at this a little more :grin:

whatever9:
I have taken the sleep out, and it still doesn't give me the result I want

Try and keep us up to date. Post the latest version of your code. I am not going to edit a previous version you posted in case I do it differently from the way you have done it.

...R