Show Posts
Pages: [1]
1  Products / Arduino Due / Re: DAC support on: January 06, 2013, 11:34:55 am
@cmaglie

I believe i've just opened pull request for this issue.

V.
2  Products / Arduino Due / Re: DAC support on: January 05, 2013, 04:33:11 pm
@jgmdavies

This modification seem to fix this buggy behaviour:
Code:
diff --git a/hardware/arduino/sam/cores/arduino/wiring_analog.c b/hardware/arduino/sam/cores/arduino/wiring_analog.c
index 58bd87a..97f50e8 100644
--- a/hardware/arduino/sam/cores/arduino/wiring_analog.c
+++ b/hardware/arduino/sam/cores/arduino/wiring_analog.c
@@ -243,8 +243,8 @@ void analogWrite(uint32_t ulPin, uint32_t ulValue) {
 
                        // Write user value
                        ulValue = mapResolution(ulValue, _writeResolution, DACC_RESOLUTION);
-                       while ((dacc_get_interrupt_status(DACC_INTERFACE) & DACC_ISR_TXRDY) == 0);
                        dacc_write_conversion_data(DACC_INTERFACE, ulValue);
+                       while ((dacc_get_interrupt_status(DACC_INTERFACE) & DACC_ISR_EOC) == 0);
                        return;
                }
        }
also with this change should desired value be on output pin by the time analogWrite() exits. Opinions?

V.
3  Products / Arduino Due / Re: DAC support on: January 05, 2013, 12:08:03 pm
@jgmdavies

Insertion of some delay between first two writes is perfectly acceptable workaround for me, but IMO this behaviour is bug and should be fixed. Am i crying on wrong place(forum)?
4  Products / Arduino Due / Re: DAC support on: January 05, 2013, 11:45:19 am
@jgmdavies

I tried your code and from what i can tell (using Velleman HPS5), it works as expected, BUT it is equivalent to example from my first post which works as expected:
Code:
void setup()
{
analogWrite(DAC0, 255);
delayMicroseconds(200);
analogWrite(DAC1, 255);
}
void loop(){}
both outputs are at 2.8V, what is NOT working is this piece of code:
Code:
void setup()
{
analogWrite(DAC0, 255);
analogWrite(DAC1, 255);
}
void loop(){}
using this code DAC0 is at 0.54V and DAC1 at 2.8V
V.
5  Products / Arduino Due / Re: DAC support on: January 05, 2013, 11:15:47 am
@jgmdavies

i guess you are writing DAC in loop() but my (non-working) example was writing DAC in setup(), your code also has delay before writing second DAC channel, just like my second (working) example. In my opionion, there is bug in analogWrite(), related to initialization of DAC.
V.
6  Products / Arduino Due / Re: DAC support on: January 05, 2013, 07:45:50 am
@jgmdavies

Hi, i'm using Arduino 1.5.1 which allready contains this patch.

V.
7  Products / Arduino Due / Re: DAC support on: January 05, 2013, 07:00:40 am
Hello,
i'am experiencing the same problem as smay4finger described in original post, using this code:
Code:
void setup() {
  analogWriteResolution(12);
  analogWrite(DAC0, 4095);
  analogWrite(DAC1, 4095);
}
void loop(){}
however, this code set correct output values:
Code:
void setup() {
  analogWriteResolution(12);
  analogWrite(DAC0, 4095);
  analogWrite(DAC1, 4095);
  delay(2);
  analogWrite(DAC0, 2047);
  analogWrite(DAC1, 1023);
}
i suspect problem in this line in wiring_analog.c:
Code:
while ((dacc_get_interrupt_status(DACC_INTERFACE) & DACC_ISR_TXRDY) == 0);
but you guys know better.
Regards,Vladimir
Pages: [1]