Solution-ATtiny can not synchronize device with programmer

General discussion on mikroBasic PRO for AVR.
Post Reply
Author
Message
nealbert
Posts: 13
Joined: 07 Jun 2013 04:40

Solution-ATtiny can not synchronize device with programmer

#1 Post by nealbert » 01 Jan 2015 03:11

Some of you may have discovered that you can successfully program an Atmel ATtiny MCU once, but when you try to re-program it you get the message “ERROR : can not synchronize device with programmer”. For me, it seems to occur more often when trying to use the Internal Oscillator as the clock source.

This is a method I have tested that will allow you to re-program Atmel ATtiny MCUs successfully over and over. My example is based on an Attiny13A. My development system is as follows:
Mikroelektronika EasyAVRv7
MikroBasic Pro for AVR v6.0.0
AVRFlash utility v2.14
Make sure these switches are ON..SW10-6, SW3-6, SW3-7, SW3-8. All others OFF.
The jumper just to the left of DIP8 should be on RS.
The External Clock jumper (just below DIP8) should be on PB3
Project Settings in mikroBasic : Attiny13A, 8.000MHz

Here's the short answer that has ONLY been tested on the above configuration...

ALWAYS turn off power to the Development Board (EasyAVR7) before starting AVRFlash Utility. (ie, before clicking on Build and Program). Turn power on after AVRFlash starts. That's it in a nutshell. Failure to turn off power will, most likely, brick the chip!

<<< Software developers at mikroElektronika, please see questions/suggestions at end >>>

-------------------------------------------------------------------------------------------------

If you're interested, here's the long version. This method should work with Basic, C or Pascal compilers since the problems you may have been experiencing are NOT due to the compilers The problem lies in the AVRFlash utility.

1. Start a new project and write a simple program (or modify one of the example programs provided by mikroElektronika like I did) for your Attiny chip. The following program will strobe the the 6 ports of the Attiny13A and will illuminate the PORTB LEDs. (well, really it will only illuminate 5 LEDs, but I'll explain how to turn on PORTB-5 in another thread)

Code: Select all

program Attiny13A_LED_chaser_shift_register
' This a stripped down version of the program “LED_Curtain”
'courtesy and copyright of mikroElektronika , 2013

' Declarations section 
dim counter as byte

sub procedure Wait()
  Delay_ms(400)
end sub

main:
  DDRB = 0xFF     ' set PORTB direction to be output
  PORTB = 0x00    ' turn OFF the PORTB leds

  while TRUE
    for counter = 0 to 5
      PORTB = PORTB or 1 << counter
      Wait()
    next counter

    counter = 0
    while (counter < 6)
        PORTB = PORTB and not(1 << counter)
        wait()
        Inc(counter)
    wend
  wend
end.

2. Make sure your EasyAVR board is turned OFF. This is VERY IMPORTANT.
3. Build & Program (CTRL-F11) the Hex file. The program should compile without errors and the AVRFlash utility should start.
4. Change the clock source settings in AVRFlash to “Cal. Internal RC Oscillator-9.6MHz”.
5. Leave all other settings at their default setting.
6. Now, turn ON the EasyAVR board.
7. Using the AVRFlash utility, WRITE (F11) the HEX file to the Attiny13A.
8. You're done. Chip should be programmed, LEDs will be flashing. Try changing the numeric value of Wait(). Repeat the above steps to re-program the chip, remembering to TURN OFF the EasyAVR board BEFORE starting AVRFlash ( before clicking on Build & Program)

The reason this method works is twofold...
First, if your EasyAVR board is powered up when you Build & Program (IE. Start the AVRFlash utility), the flash utility will automatically try to program the chip using the default clock setting ”External Clock”. From my experience a brand new chip can tolerate this setting. You can clear the “can not synchronize...” error message, change the clock to Internal Oscillator and successfully write to the chip. But if you're trying to re-program a chip and the utility is set to “External Clock” you'll brick the chip.
Second, the AVRFlash utility does not remember settings from the last time you programmed a chip. It always reloads it's default values.

So, 2 questions/suggestions to the software developers at mikroElektronika...
1. Can you give us way to start the AVR Flash utility without it automatically trying to program the chip? Maybe “Build & Start”?
2. Can you give us the option to either use default settings or use “previously used” settings for all the clock, fuse and Lock Bit settings? Or perhaps you can create a “Clock Source” dialog box in the Project Settings and just import that data into AVRFlash like you currently do with the Device Name and Clock Frequency.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Solution-ATtiny can not synchronize device with programm

#2 Post by filip » 08 Jan 2015 13:44

Hi,

First of all, I apologize for the inconvenience with our software/hardware.
Some of you may have discovered that you can successfully program an Atmel ATtiny MCU once, but when you try to re-program it you get the message “ERROR : can not synchronize device with programmer”. For me, it seems to occur more often when trying to use the Internal Oscillator as the clock source.
This is a really common issue which is related to the SPI programming frequency.

The minimal SPI programming frequency that can be used with the on-board AVRFlash programmer is 1 MHz, so setting internal clock Fuse bit that is below this minimum
(for ATtiny13 it is 128 kHz) will produce the issue that you reported, because the programmer cannot supply 128 kHz clock.
1. Can you give us way to start the AVR Flash utility without it automatically trying to program the chip? Maybe “Build & Start”?
If you are in the compiler's IDE, the programming will start automatically when the AVR Flash is invoked.
To ensure this issue will not happen, please set the Fuses correctly (oscillator type mainly) in the Project Settings Window, do not select Internal 128kHz oscillator.
If you wish, you can manually start AVR Flash from the Start menu, for example.
2. Can you give us the option to either use default settings or use “previously used” settings for all the clock, fuse and Lock Bit settings? Or perhaps you can create a “Clock Source” dialog box in the Project Settings and just import that data into AVRFlash like you currently do with the Device Name and Clock Frequency.
You can save your Fuse bit setting to a scheme and load it when you start a new project with this MCU or when you modify the existing Fuse bits and you want to revert them back to the original state.

Regards,
Filip.

nealbert
Posts: 13
Joined: 07 Jun 2013 04:40

Re: Solution-ATtiny can not synchronize device with programm

#3 Post by nealbert » 14 Jan 2015 23:00

Filip, thanks for the reply. Unfortunately, I am not trying to program the AtTiny below 1 MHz. I'm using the Internal Calibrated 9.6 MHz oscillator (I tried the 4.8 MHz frequency and get the same results).

To further ad to the mystery, right after I posted my "solution" I was reprogramming an ATTiny13. The program was something similar to LED_Curtain.mbav. I reprogrammed the chip successfully 3 times, each time ONLY changing 1 variable and following my "solution" to the letter. On the 4th attempt to reprogram I got the "cannot synchronize" error. So basically, everything I said in my original post is garbage!

So now it looks like I back to square one. I have ATTiny chips I can't reprogram and I have no idea why not. Have you done any testing (reprogramming) of ATTiny13 processors to see if you have the same problems I do?

joda
Posts: 6
Joined: 20 Mar 2011 19:07

Re: Solution-ATtiny can not synchronize device with programm

#4 Post by joda » 04 Mar 2018 01:31

Hi!
I know this is an old thread, but I'm already run into the same problem "can not synchronize device with programmer".

I use the EasyAVR5 dev board and AVRFlash utility.
I tried to use the Attiny13A with an external osc. and seems to bricked the uC.

So, my question:
If this situation happens, is there any possibility to un-brick the uC?
I mean, to erase or whatever and re-use the uC?

My best regards.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Solution-ATtiny can not synchronize device with programm

#5 Post by filip » 05 Mar 2018 14:19

Hi,

Yes, it is possible to unbrick the MCU using the parallel programmer.

Regards,
Filip.

joda
Posts: 6
Joined: 20 Mar 2011 19:07

Re: Solution-ATtiny can not synchronize device with programm

#6 Post by joda » 05 Mar 2018 19:51

Hi!
I'm already solved this problem and here is what I did:

I wrote a simple software for an Attiny2313 to toggle one pin as fast as it is possible.
In my case it was the PB1.

then I connected my USBISP programmer to the Attiny13 which was bricked.

The PB1 from the Attiny2313 connected to the CLKIN pin on the Attin13.


Then I reset to default the fuse and sec. bit's to default with the Khazama AVR Programmer.
I used the lowest programming frequency setup in Khazama AVR Programmer which is I think 500Hz.

And now the Attiny13 is already saved and working.

My best regards.

robert_d1968
Posts: 145
Joined: 14 Nov 2012 00:30
Location: China
Contact:

Re: Solution-ATtiny can not synchronize device with programm

#7 Post by robert_d1968 » 03 Apr 2018 14:53

Yeah, This is a problem on the mikro pro for arm too.. Every time it gets used it right out of the gate tries to program the chip, has not bricked any as of yet, but it really is bad if you are trying to check the programming on a chip and it gets erased on the start of the programming software!

Mikro, This needs to be fixed... No more auto program on the start of the program to be started! You are erasing what needs to be checked on my end. I have erased the program on countless chips because of this issue..

Yet it still remains today, the same as bugs 6 years ago that don't get fixed. I need to remind myself why I still use this software!

joda
Posts: 6
Joined: 20 Mar 2011 19:07

Re: Solution-ATtiny can not synchronize device with programm

#8 Post by joda » 03 Apr 2018 16:27

Ok, lets call MikroElektronika support team and ask why is this problem still here.

MikroElektronika support team pleas answer to as.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Solution-ATtiny can not synchronize device with programm

#9 Post by filip » 04 Apr 2018 15:21

Hi,

I know this problem happens time from time, and the source of this issue is the minimal clock of the AVR SPI programming which is set to 1 MHz.
So if you go under this limit, you may experience this problem.

If the MCU is already programmed with this clock (for example brand new one), then it could be difficult to program the MCU,
so you will have to use a parallel programmer or utilize the solution given here by joda

I will speak to developers and see if there is a solution or workaround for this and let you know.

Regards,
Filip.

Post Reply

Return to “mikroBasic PRO for AVR General”