Can't program ATmega32U4 after setting CKDIV8 = 1 - Page 1
Forum section: electronics / general

author: avf32
author_rank: Newbie
timestamp: August 29, 2021, 12:33:57 pm
content: Hi all,My ATmega32U4 adventure continues... Everything was working fine until I tried to set the CKDIV8 bit in LFUSE to 1.After this, I can no longer program it, it just says "target doesn't answer". I've double-checked all the connections, and I'm pretty sure that I didn't change any other fuse bits when trying to set CKDIV8 (I set LFUSE to 0xD2, it was 0x52 before that).Is this expected? Can I recover from this somehow? Is it bricked?Thanks,Alex

author: HB9EVI
author_rank: Frequent Contributor
timestamp: August 29, 2021, 01:08:31 pm
content: I guess you have to lower the ISP clock rate; in avrdude by setting the -B flag to 8 or 16

author: bingo600
author_rank: Super Contributor
timestamp: August 29, 2021, 01:42:19 pm
content: Quote from: HB9EVI on August 29, 2021, 01:08:31 pmAs HB9EVI says you have to lower your programming speed.The AVR supports a Max programming speed of MCU-Freq/4 , so if you had an 8MHz clock , and divide by 8 ==> 1MHz , then Max programming speed is 1MHz/4 ==> 250KHz/Bingo

author: avf32
author_rank: Newbie
timestamp: August 29, 2021, 01:56:22 pm
content: Thanks both. I saw that suggestion elsewhere on the Internet, and I've tried with various values for -B (including 8 and 16), and it makes no difference.I do get a warning from avrdude:avrdude: set SCK frequency to 32000 Hzavrdude: warning: cannot set sck period. please check for usbasp firmware update.I suspect this might be why -B doesn't seem to do anything? Other sources say that this is because I have a USBASP with Chinese firmware which autodetects the programming speed? Is it autodetecting incorrectly in my case, and ignoring the -B option? I have a second USBASP on order, so I'll be able to flash that to stock firmware to see if that helps.However, I unprogrammed the CKDIV8 bit (= 1), so as I understand it, that should have increased the frequency from 1MHz (internal 8MHz oscillator divided byto 8MHz, rather than decreasing it.

author: madires
author_rank: Super Contributor
timestamp: August 29, 2021, 02:25:59 pm
content: The fuse bits can be a bit confusing. The default for CKDIV8 is 0 (programmed, enabled). So setting it to 1 (unprogrammed) will disable the 8:1 prescaler. Old USBasp firmwares don't support the low-SCK function, but you can update the firmware:https://blog.podkalicki.com/how-to-update-avr-usbasp-firmware-to-latest-version/

author: avf32
author_rank: Newbie
timestamp: August 29, 2021, 02:37:14 pm
content: Quote from: madires on August 29, 2021, 02:25:59 pmThanks.Yes, I was setting it to 1 (unprogrammed) to disable the prescaler -- that was my intention.I guess I'll wait until I get the second USBASP so that I can change the firmware and see if that makes any difference.

author: avf32
author_rank: Newbie
timestamp: September 09, 2021, 02:46:46 pm
content: Got my new USBASP. Whatever firmware it's running, I don't get the "cannot set sck period" warning with it.I've tried different values for -B, and still nothing:$ avrdude -B 16 -p m32u4avrdude: set SCK frequency to 32000 Hzavrdude: error: program enable: target doesn't answer. 1avrdude: initialization failed, rc=-1Double check connections and try again, or use -F to overridethis check.avrdude done. Thank you.Is it worth trying to flash the stock firmware onto one of my USBASPs and try again? I'm not sure what else to try, except buying a new chip, which seems ridiculous. Any ideas appreciated!Thanks!

author: mikerj
author_rank: Super Contributor
timestamp: September 10, 2021, 09:43:40 am
content: Perhaps you inadvertently wrote to the SPIEN fuse and disabled the SPI interface? If so you'll need a high voltage programmer to recover it.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: September 20, 2021, 02:04:21 pm
content: The whole concept of those confusing bits is indeed quite ridiculous.At some time it will bite several hours out of the time of each and every developer who works with the AVR chips.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: September 20, 2021, 02:11:55 pm
content: Quote from: Doctorandus_P on September 20, 2021, 02:04:21 pmYes - the biggest problem with the AVR interface is that it needs a clock to do ISP - this is the root cause of most of these problems as multiple things can cause teh clock to either not be there or be the wrong speed.Atmel really didn't understand the needs of production programming, as evidenced by how long it took to include the config fuses in the hex file.