MCU/MiniCore, what have I done? have I " bricked" or damaged my 328p-AU

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

Hi All
I have been using MiniCore quite successfully, I find it easy to use and great but my last Two MCU's will now not burn bootloader, upload sketches and wont respond to Nick gammons great Board Detector Program, yet the software that did successfully load is still running ok, I am using a "bare bones " set up an 328p_AU (on a breakout board" with decoupling caps and a 10k pull up on reset. I have two other boards set at 1 Mhz internal and they are working at the moment but would like to no what I have done because I don't want to repeat it, do you think the un responsive board has had it? I have also tried a FTDI USB to serial board and that doesn't work either. Is it possible I have "Bricked" the chip? I am quite a newbie and running out of ideas. if it helps I will show you the code I am using, it simply has two switches to switch between deep sleep and awake with an LED my goal is to run on batteries  so the deep sleep is what i'm playing with but afraid that I'm doing something wrong and can I fix the chip that runs but wont talk to me?..Please help as I was really getting along nicely and learning a lot.One thing more could it be that I set the internal clock to 1Mhz and forgot to remove the prescaler code which would have divided the 1Mhz by 8 again? below is my sketch

 

/*
  DDRD |= 1 << 5; is an example of setting a bit in the "data direction register" in this case port D bit 5 using an "OR" all other bits unchanged
  DDRD &= ~(1 <<5); is an example of clearing a bit in the "data direction register" in this case port D bit 5 using an " AND NOT" all other bits unchanged

  Whole object here is to use port manipulation instead of "arduino functions" (as much as I no how to at moment)

  Andy Browns first go at direct port manipulation so don't take the mickey!
*/

#include "avr/sleep.h"
#define wake_pin 3                 // AU chip, pin 1 (PD3)
#define sleep_pin 4                // AU chip, pin 2 (PD4)
#define led_pin 5                  // AU chip, pin 9 (PD5)

void setup()
{
  DDRD = 0x20;                     // setting all pins of port D to 0 (INPUTS) except the led pin which is set to 1 (OUTPUT)
  PORTD = 0x38;                    // setting wake_pin, sleep_pin, led_pin to 1 (HIGH)
}

void loop()
{
  if (bit_is_clear(PIND, sleep_pin))                 // checks to see if sleep_pin button has been pressed setting sleep_low
  {
    goto_sleep();                                    // call sleep function
  }
  PORTD |= 1 << led_pin;                             // sets led_pin to 1 (HIGH)
}

void goto_sleep()                                    // sleep function
{
  PORTD &= ~(1 << led_pin);                          // sets led_pin to 0 (LOW)
  ADCSRA &= ~(1 << 7);                               // by writing bit 7 to zero, the ADC is turned off
  set_sleep_mode (SLEEP_MODE_PWR_DOWN);              // AVR power mode
  cli();                                             // clear interrupts before attaching interrupts
  sleep_enable();
  attachInterrupt(digitalPinToInterrupt(wake_pin), sleep_wakeup, LOW);         // attach interrupt to wake pin and check for low on wake_pin if true then goto ISR
  MCUCR = bit (BODS) | bit (BODSE);                  // this stuff switches off "brown out" detection
  MCUCR = bit (BODS);                                // must be done within 4 cycles of the above
  sei();                                             // sets interrupts
  sleep_cpu();                                       // cpu stops here until interrupt sensed, then sleep_wakeup (ISR)
}

void sleep_wakeup()                                  // ISR ( interrupt service routine) function
{
  sleep_disable();
  detachInterrupt(digitalPinToInterrupt(wake_pin));  // disengage interrupts
  ADCSRA |= (1 << 7);                                // by writing bit 7 to one, the ADC is turned on
}

also I have an error code if i try to use the Arduino as ISP, as I said other chips are working fine

 

Sketch uses 830 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 13 bytes (0%) of dynamic memory, leaving 2035 bytes for local variables. Maximum is 2048 bytes.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM5 -b19200 -Uflash:w:C:\Users\andy\AppData\Local\Temp\arduino_build_586113/sleep_test3.ino.hex:i 

avrdude: Version 6.3-20171130
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM5
         Using Programmer              : arduino
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x000000 (retrying)

An error occurred while uploading the sketch
Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.

avrdude done.  Thank you.

I hope you can help me and that I have used the forum correctly

 

Regards

 

Andy

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

Welcome to the Forum!

 

Your micro is still running its program, so that is a good thing.

 

If your micro is running on its internal 8 MHz RC Oscillator as its clock source, and the Divide by 8 Fuse is set to Divide by 8, then the micro is running at 1 MHz.

 

The ISP programmer has to run at < 1/4 the micro's clock speed, so < 250 kHz.

 

Depending upon what programmer you have, you like just have to slow it down so that it doesn't run to fast for the currently selected 1 MHz clock that the micro is running at.

 

How one does this depends upon which programmer you have.

 

JC

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

For reference this link is where the SPI clock is set in the ArduinoISP sketch:

 

https://github.com/arduino/Arduino/blob/e5252adfc0be53a57f4bb95ab438908bffdc23e9/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino#L53

 

So the default should work if it has not been changed.

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

Thanks to you and all for my welcome.

 

Firstly Im using an Uno as ISP, also what you have said is very useful as I'm devoting my learning experience to one micro that's the 328p-AU. 

There is a possibility (cos I was messing about) that the internal clock source was already set to 1 Mhz and I had left in the divide by 8 prescaler code, does that mean that the 1Mhz would then be divided by 8? If this happened would the code still run ok? also what (if any) would be the fix? perhaps slow down the ISP as another gentleman has suggested? Is there such a thing as a "factory reset" in the world of MCU's?.

Thank You for your help so far and if you need to no anymore settings or data I will get it for you, one thing's for sure It's very interesting for me, but I hope not to bother you too much!

 

regards

Andy

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

Hi and thanks 

Will try your suggestion as well as another gentleman's thoughts you both seem to be pointing to the same problem...operator error!

 

Thanks again

Andy

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

Hi,

still no solution i'm afraid,but what I did do is solder a new 328p-AU onto a new breakout board, I then set an UNO as an ISP as normal and wired up the chip appropriately and the chip responded no problem so I went on an used Arduino as an ISP and uploaded a sketch to the new chip and again no problem. So I no that there is no wiring error because I simply replaced new chip with the troublesome one and it was unable to enter program mode. At this point I dont no what to do and i don't simply put in the bin and say "oh well ya win some ya lose some"...do you have any more sugestions as what to try please?

 

Regards 

 

Andy

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

Post an exact schematic of your micro's circuit.

 

Post a photo of the setup, the micro and the programmer.

 

Tell the clock speed the Uno ISP programmer is programming at.

 

With that info we might have a better idea on what you need to do.

 

JC

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

HI

I hope i've attached the file correctly!...the breakout board is the first board I made with Kicad and is simply 16 pins on the left and 16 on the right. The top three breadboards are from left to right 1Mhz internal, 8Mhz internal, and a 16Mhz external all have been programed with both Nick Gammons software (detecter,programer) and UART (FTDI) and MiniCore and work fine.

The board connected to the UNO is the troublesome one! The  Uno is set as ISP from the IDE examples, I dont no how to change speeds it's just standard. I have 0.1uF caps on both supplies (VCC,AVCC) and a pull up on reset I will include the sketch that is on the boards, the same sketch that the "bad" board still runs ok but wont respond. From what I've been reading I think there is some way to disable programing not sure if I did it. Here's the sketch

 

/*
  DDRD |= 1 << 5; is an example of setting a bit in the "data direction register" in this case port D bit 5 using an "OR" all other bits unchanged
  DDRD &= ~(1 <<5); is an example of clearing a bit in the "data direction register" in this case port D bit 5 using an " AND NOT" all other bits unchanged

  Whole object here is to use port manipulation instead of "arduino functions" (as much as I no how to at moment)

  Andy Browns first go at direct port manipulation so don't take the mickey!
*/


#include "avr/sleep.h"
#define wake_pin 3                 // AU chip, pin 1 (PD3)
#define sleep_pin 4                // AU chip, pin 2 (PD4)
#define led_pin 5                  // AU chip, pin 9 (PD5)

void setup()
{
  DDRD = 0x20;                     // setting all pins of port D to 0 (INPUTS) except the led pin which is set to 1 (OUTPUT)
  PORTD = 0x38;                    // setting wake_pin, sleep_pin, led_pin to 1 (HIGH)
}

void loop()
{
  if (bit_is_clear(PIND, sleep_pin))                 // checks to see if sleep_pin button has been pressed setting sleep_low
  {
    goto_sleep();                                    // call sleep function
  }
  PORTD |= 1 << led_pin;                             // sets led_pin to 1 (HIGH)
}

void goto_sleep()                                    // sleep function
{
  PORTD &= ~(1 << led_pin);                          // sets led_pin to 0 (LOW)
  ADCSRA &= ~(1 << 7);                               // by writing bit 7 to zero, the ADC is turned off
  set_sleep_mode (SLEEP_MODE_PWR_DOWN);              // AVR power mode
  cli();                                             // clear interrupts before attaching interrupts
  sleep_enable();
  attachInterrupt(digitalPinToInterrupt(wake_pin), sleep_wakeup, LOW);         // attach interrupt to wake pin and check for low on wake_pin if true then goto ISR
  MCUCR = bit (BODS) | bit (BODSE);                  // this stuff switches off "brown out" detection
  MCUCR = bit (BODS);                                // must be done within 4 cycles of the above
  sei();                                             // sets interrupts
  sleep_cpu();                                       // cpu stops here until interrupt sensed, then sleep_wakeup (ISR)
}

void sleep_wakeup()                                  // ISR ( interrupt service routine) function
{
  sleep_disable();
  detachInterrupt(digitalPinToInterrupt(wake_pin));  // disengage interrupts
  ADCSRA |= (1 << 7);                                // by writing bit 7 to one, the ADC is turned on
}

I hope this has given you something to work with I am an AVR Freak intraining!...if not please explain how Ive used the forum wrong or not answered you questions

 

regards

 

Andy

Attachment(s): 

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

The white hook up wire is hard to see, so be sure you have all GND pins connected to GND and all VCC/AVCC pins connected to VCC on your bread boards, and all VCC/AVCC pins need 100nF caps to gnd as close to the pin as possible.  All LEDS need current limiting resistors in series with the LED and port pin!  For a 3v VCC, 100 ohms should work with most LEDS.

 

If the "bad" chip is still running the program, then at least you still have a clock, if you programmed fuses, then you may have changed the reset disable pin, test by grounding the reset pin and see if the program stops, if not, then the reset disable fuse has been set, and the only way to restore it is with 12v (HV) programming option.  If that is not an option then chock it up to a learning experience and toss the chip.

Be careful with fuse settings, if you are unsure, post them on AVRFreaks and someone can verify your settings BEFORE you brick it!

 

Looks like your doing well and will be an expert Freak soon!  smiley

 

Jim

 

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

Hi, thanks for your kind remarks 

Firstly I checked every thing in my picture is correct didn't realize that it wasn't that clear! and all was well, then i grounded the "bad " chips reset pin and the program stopped and did indeed reset to the "awake" condition..so I really don't no and I will add this chip to my "to do " list, at the bottom I think! I have a HV programer for the ATtiny85 maybe someday I can have another look at this quarrelsome little guy and see what he is up to, I even went over every solder joint...just for kicks ! but it still refuses to enter programing mode. It won the battle but not the war! My next plan is write my little sketch in C++ and upload using Atmel Studio 7, I have done this before by using AVRDUDE as an external tool so that's good but, have much to learn and also gets some hardware like ICE or STK500.

Thanks for your help I hope I used the forum correctly and will no doubt need guidance again.

 

Regards 

 

Andy