Triggered off the digital input line into segmented memory. First four segments captured of a single shot run. Run begins and then reset is pressed. The first two segments are part of the reset cycle and are ignored.
void setup() {
analogWriteResolution(12); // bits of resolution
pinMode(31, OUTPUT);
analogWrite(DAC0, 0);
digitalWrite(31, LOW);
}
int analog_vh = 4095;
int analog_vl = 0;
int do_once = 1;
void loop() {
if(do_once) {
do_once = 0;
delay(10000);
digitalWrite(31, HIGH);
analogWrite(DAC0, analog_vh);
digitalWrite(31, LOW);
delay(10000);
digitalWrite(31, HIGH);
analogWrite(DAC0, analog_vl);
digitalWrite(31, LOW);
}
}
void setup() {
analogWriteResolution(12); // bits of resolution
pinMode(31, OUTPUT);
analogWrite(DAC0, 0);
digitalWrite(31, LOW);
}
int analog_vh = 4095;
int analog_vl = 0;
int do_once = 1;
void loop() {
if(do_once) {
do_once = 0;
delay(10000);
REG_PIOA_ODSR = 1<<7;
analogWrite(DAC0, analog_vh);
REG_PIOA_ODSR = 0;
delay(10000);
REG_PIOA_ODSR = 1<<7;
analogWrite(DAC0, analog_vl);
REG_PIOA_ODSR = 0;
}
}
void setup() {
pinMode(31, OUTPUT);
digitalWrite(31, LOW);
}
int do_once = 1;
void loop() {
if(do_once) {
do_once = 0;
delay(10000);
digitalWrite(31, HIGH);
digitalWrite(31, LOW);
delay(10000);
digitalWrite(31, HIGH);
digitalWrite(31, LOW);
}
}
void setup() {
pinMode(31, OUTPUT);
digitalWrite(31, LOW);
}
int do_once = 1;
void loop() {
if(do_once) {
do_once = 0;
delay(10000);
REG_PIOA_ODSR = 1<<7;
REG_PIOA_ODSR = 0;
delay(10000);
REG_PIOA_ODSR = 1<<7;
REG_PIOA_ODSR = 0;
}
}
Reducing the resolution did not change the DAC conversion time. Changing the value did though. The conversion time is related to the value and the max value. The conversion time seems short compared to the time between transitions.
Changing to port manipulation helped with that.
How do the two methods compare in terms of speed?