Help ---- Console Error when trying to flash code?

The console prints the following when I try to flash with application: Please help with error???

Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 4096
DfuSe interface name: "Internal Flash   "
Downloading to address = 0x080a0000, size = 8444
Last page at 0x080a20fb is not writeable
make[2]: *** [../../../build/module.mk:126: program-dfu] Error 74
make[1]: *** [../build/recurse.mk:12: modules/photon/user-part] Error 2
make: *** [C:\Users\ridge\.particle\toolchains\buildscripts\1.10.0\Makefile:86: flash-user] Error 2
The terminal process "C:\Users\ridge\.particle\toolchains\buildtools\1.1.1\bin\bash.exe '-c', 'make -f 'C:\Users\ridge\.particle\toolchains\buildscripts\1.10.0\Makefile' flash-user -s'" terminated with exit code: 2.

The code:

/*
 * Project DAC_LED
 * Description:
 * Author:
 * Date:
 */
#include <PollingTimer.h>


#define DAC_ADD 0x60
#define DAC0_VREG   0x00
#define DAC1_VREG   0x01
#define DAC_REF_CFG_REG 0x08
#define DAC_PWRDWN_REG 0x09
#define DAC_GAIN_CFG_REG 0x0A
#define BUFFER_LENGTH 1
#define GAIN2X 0x06
#define GAIN1X 0x00
#define BANDGAP_REF 0x05
#define VCC_REF 0x00

typedef struct{
  uint16_t LEDCurrent[2];
} t_SenseDataRaw;

typedef struct{
  volatile bool B_Flush : 1;
  volatile bool AD_Complete : 1;
}t_hardFlags;

unsigned int psEn = D7, LED1_current = A2, LED2_current = A3, Button_Flush = D5;

unsigned int testData = 0, rd[2] = {0};
float ADValues[2] = {0};

t_SenseDataRaw SensorData = {0};
t_hardFlags ISR = {false};

PollingTimer secTmr(1500), ADconvTmr(1), standOffTmr(500);  //load timers with ms

void IRQ_BFlush(void);

void setup() {

  Serial.begin(9600);

  pinMode(psEn, OUTPUT);
  pinMode(Button_Flush, INPUT_PULLUP);

  attachInterrupt(Button_Flush, IRQ_BFlush, FALLING);

  Wire.setSpeed(CLOCK_SPEED_400KHZ);
  Wire.begin();

  //DAC power = on 0x9
  Wire.beginTransmission(DAC_ADD);
  Wire.write(DAC_PWRDWN_REG << 3);
  Wire.write(0);
  Wire.write(0);  
  //DAC Vref= 3.3 0x8
  Wire.write(DAC_REF_CFG_REG << 3);
  Wire.write(0);
  Wire.write(VCC_REF);  
  //DAC gain = 1X 0xA
  Wire.write(DAC_GAIN_CFG_REG << 3);
  Wire.write(GAIN1X);
  Wire.write(0);  
  Wire.endTransmission();

  Wire.beginTransmission(DAC_ADD); 
  Wire.write((DAC_GAIN_CFG_REG << 3) | 0x06); 
  Wire.endTransmission(false);
  Wire.requestFrom(DAC_ADD, 2);
  for (uint8_t i = 0; i < 2; i++){
    rd[i] = Wire.read();
  }

}

void loop() {

  if (ISR.B_Flush){
    ISR.B_Flush = false;
    detachInterrupt(Button_Flush);
  
    Wire.beginTransmission(DAC_ADD);
    Wire.write(DAC1_VREG << 3);
    Wire.write((testData >> 4) & 0x0F); //MSB
    Wire.write(testData & 0xFF); //LSB
    Wire.write(DAC0_VREG << 3);
    Wire.write((testData >> 4) & 0x0F); //MSB
    Wire.write(testData & 0xFF); //LSB
    Wire.endTransmission();

    secTmr.start();
    digitalWrite(psEn, HIGH);
    standOffTmr.start();
    //must holdoff until power comes up ~130ms after enabled
    while(!standOffTmr.expired());  
   
    SensorData.LEDCurrent[0] = analogRead(LED1_current);
    SensorData.LEDCurrent[1] = analogRead(LED2_current);

    ADValues[0] = (float)SensorData.LEDCurrent[0] * 3.3/4096;
    ADValues[1] = (float)SensorData.LEDCurrent[1] * 3.3/4096;

    while (!secTmr.expired());
    
    secTmr.stop();
    digitalWrite(psEn, LOW);

    Serial.printlnf("LED1 Current = %.2f; LED2 Current = %.2f", ADValues[0], ADValues[1]);

    testData += 10;
    if (testData > 4095)
      testData = 0;

    attachInterrupt(Button_Flush, IRQ_BFlush, FALLING);
  }
}

void IRQ_BFlush(){
  ISR.B_Flush = true;
}

You’ve tagged this post for the argon, but the compiler output suggests you are compiling/flashing for the photon. I’d recommend checking your project settings in Workbench.

6 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.