Millis and DAC square wave as monitored by TI-Vernier.. interesting bug

I’ve recently begun programming on the Due, and have been monitoring my pin outputs using a voltage probe and the data logging software on a TI nspire CX CAS calculator (see the screenshot attached).

After playing with the PWM pins, I attempted to make a square wave using pin DAC0. Here is the code:

void setup() {
  // put your setup code here, to run once:

int millisCurrent = 0;
int millisPrevious = 0;
int analogSetting1 = 800;
int analogSetting2 = 400;

void loop() {
  millisCurrent = millis();
if (millisCurrent-millisPrevious <200)

if (millisCurrent-millisPrevious >600)
{millisPrevious = millis();}

The idea is to have two different levels of analog output power stored, and to switch between them as the timer carries on. The first setting should be active for the first 200ms of a cycle, then the second setting until 600ms, when the cycle resets. Therefore the duration of analogSetting2 should be two times that of analogSetting1, right? I’m reading the opposite duration/amplitude relationship on my TI (that’s the screenshot). Or have I just been staring at this for too long?

You may need to use analogWriteResolution - I don't know what the default resolution is but if it's 8 bits then 800 mod 256 = 32 which is less than 400 mod 256 = 144, which would explain why 800 gives you a lower output voltage than 400.

That's it, well at least I got my newbie post out of the way. I was using parameter range 0-1023, which applies to analogRead. 0-255 is the range for analogWrite.