Arduino Zero Overheating

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello All,

 

I noticed that uploading my code would make the device not recognizable anymore, then uploading an empty project would make it detectable again. I'm woundering how this is possible. Also lately its starting to get really hot and it doesnt upload anymore. The upload before was done when i pressed the reset button, then shortly it would be recognizable and i managed to upload the code. 

 

The code i'm currently uploading is the following:

 

#include <Arduino.h>
#include "..\Functions\functions.h"

#include "..\StepperMotor\StepperMotor.h"

void _step();

void InterruptHardwareX() {
  ;
};
void InterruptHardwareY() {
  ;
};

void TCC1_Handler() {
  NVIC_ClearPendingIRQ(TCC1_IRQn);                                              // Clear pending for timer interrupt

  // Check for overflow (OVF) interrupt
  if (TCC1->INTFLAG.bit.OVF && TCC1->INTENSET.bit.OVF)
  {
    TCC1->INTFLAG.reg = TCC_INTFLAG_OVF;        // Clear the OVF interrupt flag
  }

  // Check for match counter 0 (MC0) interrupt
  if (TCC1->INTFLAG.bit.MC0 && TCC1->INTENSET.bit.MC0)
  {
    _step();
    TCC1->INTFLAG.reg = TCC_INTFLAG_MC0;         // Clear the MC0 interrupt flag
  }
};

void InitializeRobot() {
  // Set The CPU To Run At Maximum = 48 MHz & Wait For Sync Status Idle
  PM->CPUSEL.reg = PM_CPUSEL_CPUDIV_DIV1;                                       // Select cpu division (48 MHz)
  PM->APBCMASK.reg |= PM_APBCMASK_TCC1;                                         // Enable peripheral clock for timer 1
  while (GCLK->STATUS.bit.SYNCBUSY) { };

  // Set The Global Clock: Improve Duty Cycle, Enable And Clock Selection
  GCLK->GENCTRL.reg = GCLK_GENCTRL_IDC;                                         // Improve duty cycle (50 % / 50 %)
  GCLK->GENCTRL.reg |= GCLK_GENDIV_DIV(3);                                      // Set clock division (48/3 = 16 MHz)
  GCLK->GENCTRL.reg |= GCLK_GENCTRL_GENEN;                                      // Enable general clock
  GCLK->GENCTRL.reg |= GCLK_GENCTRL_SRC_DFLL48M;                                // Set DFLL48M as source for the clock
  GCLK->GENCTRL.reg |= GCLK_GENCTRL_ID(4);                                      // Set general clock 4
  while (GCLK->STATUS.bit.SYNCBUSY) { };

  // Feed Clock To Timer, Select Clock 4 & Enable Clock
  GCLK->CLKCTRL.reg = GCLK_CLKCTRL_ID_TCC0_TCC1;                                // Feed clock to timer
  GCLK->CLKCTRL.reg |= GCLK_CLKCTRL_GEN_GCLK4;                                  // Select general clock 4
  GCLK->CLKCTRL.reg |= GCLK_CLKCTRL_CLKEN;                                      // Enable general clock
  while (GCLK->STATUS.bit.SYNCBUSY) { };                                        // Wait for general clock to be synced
  //while (GCLK->CLKCTRL.reg & GCLK_CLKCTRL_CLKEN) { };

  // TCC0->CTRLA.reg = TCC_CTRLA_PRESCALER_DIV16 | TCC_CTRLA_PRESCSYNC_GCLK;
  // TCC0->WEXCTRL.bit.OTMX = 0x01; // Route CC0 to OTMX[6];

  // Configure The Timed Interrupt For MotorControl
  TCC1->INTENCLR.reg = TCC_INTENCLR_MC0;                                        //
  TCC1->CTRLA.reg &= ~(TCC_CTRLA_ENABLE);                                       // Disable the timer
  //while (TCC1->SYNCBUSY.bit.ENABLE) { };                                        // Wait till timer is disabled
  TCC1->CTRLA.reg = TCC_CTRLA_PRESCALER_DIV1024;                                // Set timer division factor
  TCC1->CTRLA.reg |= TCC_CTRLA_PRESCSYNC_GCLK;                                  // Timer presynchronization
  TCC1->WAVE.reg = TCC_WAVE_WAVEGEN_MFRQ;                                       // Set the wavegeneration to match frequency
  TCC1->COUNT.reg = 0;                                                          // Initialize count to 0
  TCC1->CC[0].reg = 5208;                                                       // Set compare value
  //while (TCC1->SYNCBUSY.bit.CC0) { };                                           // Wait for compare synchronization done
  // Period is ignored in MFRQ
  //TCC1->PER.reg = 100;
  //while (TCC1->SYNCBUSY.bit.PER) { };

  TCC1->INTFLAG.reg = TCC_INTFLAG_MC0;                                          //
  TCC1->INTENSET.reg = TCC_INTENSET_MC0;                                        //
  TCC1->CTRLA.reg |= TCC_CTRLA_ENABLE;                                          // Enable the timer
  //while (TCC1->SYNCBUSY.bit.ENABLE) { };
  PORT_IOBUS->Group[0].OUT.reg |= PORT_PA20;

  // Set The Timed Interrupt Priority To The Highest & Enable
  NVIC_ClearPendingIRQ(TCC1_IRQn);                                              // Clear pending for timer interrupt
  NVIC_SetPriority(TCC1_IRQn, 0);                                               // Set interrupt to highest priority
  NVIC_EnableIRQ(TCC1_IRQn);                                                    // Enable the interrupt event handler

  // Configure External Interrupt For Remote X-Direction
  //attachInterrupt(2, InterruptHardwareX, CHANGE);

  // Configure External Interrupt For Remote Y-Direction;
  //attachInterrupt(3, InterruptHardwareX, CHANGE);
};

unsigned long TimeStart = 0;

void setup() {
    //
    PORT_IOBUS->Group[0].DIR.reg |= PORT_PA15;
    PORT_IOBUS->Group[0].DIR.reg |= PORT_PA18;
    PORT_IOBUS->Group[0].DIR.reg |= PORT_PA14;
    PORT_IOBUS->Group[0].DIR.reg |= PORT_PA19;

    PORT_IOBUS->Group[0].OUT.reg |= PORT_PA15;
    PORT_IOBUS->Group[0].OUT.reg |= PORT_PA18;

    // For testing
    PORT_IOBUS->Group[0].DIR.reg |= PORT_PA08;
    PORT_IOBUS->Group[0].DIR.reg |= PORT_PA09;
    PORT_IOBUS->Group[0].DIR.reg |= PORT_PA20;
    PORT_IOBUS->Group[0].DIR.reg |= PORT_PA21;

    PORT_IOBUS->Group[0].OUT.reg &= ~PORT_PA08;
    PORT_IOBUS->Group[0].OUT.reg &= ~PORT_PA09;
    PORT_IOBUS->Group[0].OUT.reg &= ~PORT_PA20;
    PORT_IOBUS->Group[0].OUT.reg &= ~PORT_PA21;

    TimeStart = micros();
    InitializeRobot();
    /*PORT_PA00E_TCC2_WO0;
    PORT_PA01E_TCC2_WO1;
    PORT_IOBUS->Group[0].CTRL.reg = 1;
    */
}

int ActiveStep = 0;

void _step() {
   // This routine handles the steps of the stepper motor.

   switch (ActiveStep) {
   case 0:
     PORT_IOBUS->Group[0].OUT.reg &= ~PORT_PA14;
     PORT_IOBUS->Group[0].OUT.reg &= ~PORT_PA19;
     break;
   case 1:
     PORT_IOBUS->Group[0].OUT.reg |= PORT_PA14;
     PORT_IOBUS->Group[0].OUT.reg &= ~PORT_PA19;
     break;
   case 2:
     PORT_IOBUS->Group[0].OUT.reg |= PORT_PA14;
     PORT_IOBUS->Group[0].OUT.reg |= PORT_PA19;
     break;
   case 3:
     PORT_IOBUS->Group[0].OUT.reg &= ~PORT_PA14;
     PORT_IOBUS->Group[0].OUT.reg |= PORT_PA19;
     break;
   };
   ActiveStep += 1;
   if (ActiveStep > 3) {
       ActiveStep = 0;
   };
};

void loop() {
    // Set CPU Clock Frequency Depending On Motor Status
    //PORT_IOBUS->Group[0].CTRL.reg = PORT_PA17;
    /*if (((micros() < TimeStart) * 4294967295 - TimeStart + micros()) >= 3000) {
      _step();
      TimeStart = micros();
    };*/
};

 

Does anyone have an idea on how to fix it or do you guys think its destroyed? I didn't manage to get the timer to work yet so if anyone has a suggestion about what i'm doing wrong i would appreciate the feedback. 

 

Kind regards,

 

 

Bob

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you applying the right supply voltage...what are your output pins hooked to (hopefully nothing for this heating test).  Otherwise you might have an output shorted or being driven by some external voltage/signal.

 

Your program itself can't make the chip hot---it can only make the i/o make it hot.

When in the dark remember-the future looks brighter than ever.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If your uC gets hot there is something wrong with the Hardware.

Either the uC itself has released some of it's smoke and does not work properly anymore, or there is some pin conflict or short circuit.

 

Not being able to re-program the chip also indicates one of the above, but I can't say which.

 

Pin conflicts can be handled in software, but without the actual schematic there is not much to say or look at the source code.

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I would just re-install the Bootloader with the onboard EDBG.

Then build and run regular Arduino example sketches.

 

If your SAMD gets hot.   It is damaged.

 

David.

Last Edited: Wed. Feb 14, 2018 - 09:34 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello All,

 

Thank you for your answers, sorry for my late response. I didn't connect anything to it so its kind of weird. I did find out though i made a programming error which i suspect caused it (somehow).

 

I used a different one and everything works fine now. 

 

david.prentice wrote:

I would just re-install the Bootloader with the onboard EDBG.

Then build and run regular Arduino example sketches.

 

If your SAMD gets hot.   It is f*cked.

 

David.

 

Could you explain on how to do this?

 

Kind regards,

 

 

Bob

Last Edited: Wed. Feb 14, 2018 - 08:01 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

SSJVegetto wrote:
its (sic) starting to get really hot

What, exactly, is getting hot?

  • The regulator?
  • The SAMD chip?
  • The EDBG?
  • Something else?
  • All of the above?

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The OP has started another thread with a timer issue so I would not bother answering to this thread anymore as it seems the OP has moved on to another A-Zero.

 

Jim

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

SSJVegetto wrote:

Hello All,

 

Thank you for your answers, sorry for my late response. I didn't connect anything to it so its kind of weird. I did find out though i made a programming error which i suspect caused it (somehow).

 

I used a different one and everything works fine now. 

 

david.prentice wrote:

I would just re-install the Bootloader with the onboard EDBG.

Then build and run regular Arduino example sketches.

 

If your SAMD gets hot.   It is f*cked.

 

David.

 

Could you explain on how to do this?

 

Kind regards,

 

 

Bob

 

1.  Run the Arduino IDE

2.  Tools->Board:  Select Zero

3.  Tools->Port:  Select COM port

4.  Tools->Programmer: select EDBG

5.  Tools->Burn Bootloader

 

6.  File->Examples: select any simple standard sketch to test on the Zero

7.  Sketch->Upload

 

(7) should Compile and Upload the sketch to your Zero  i.e. just like you would do with any Arduino.

 

If you have a problem,   quote which step number.    Explain your problem.

 

If everything goes smoothly.   Program works normally.   Zero gets hot.    ------ your Zero is damaged.   Buy a new one.

 

David.

Last Edited: Wed. Feb 14, 2018 - 09:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
your Zero is f*cked.   Buy a new one.

I believe the OP did and moved on to the Timer thread.

 

david.prentice wrote:
your Zero is f*cked. 

Technical term, Laymans term, or Freudian slip? laugh

 

JIm

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user