I am creating a standalone arduino project and I should program bootloader on the Atmega 328P.
I use an USBasp device and the MCU is recognized.
I programmed it using a video on youtube, but the LockByte was set to 0x0F so I programed it like that
Now I cannot detect the MCU anymore
Each time I try to detect I have the following message in AVRDUDE :
avrdude.exe: set SCK frequency to 1500000 Hz
avrdude.exe: warning: cannot set sck period. please check for usbasp firmware update.
avrdude.exe: error: programm enable: target doesn't answer. 1
avrdude.exe: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
I would like to reset this lock byte to the right value 0x3F, or completely erase the ship to redo the programing.
"31.1. Program And Data Memory Lock Bits
The devices provides six Lock bits. These can be left unprogrammed ('1') or can be programmed ('0') to obtain the additional features listed in Table. Lock Bit Protection Modes in this section. The Lock bits can only be erased to “1” with the Chip Erase command."
I believe Chip Erase is only available in Parallel Programming mode, or High Voltage Programming mode.
More detailed discussion here
CrossRoads:
I believe Chip Erase is only available in Parallel Programming mode, or High Voltage Programming mode.
More detailed discussion here
Nope. Chip Erase is available via ISP (as well as parallel and HV programming modes) - in fact, Chip Erase is the only way that the flash can be cleared when programming via ISP (or either of those other modes).
That's why uploading a sketch via ISP erases the bootloader - the only way it can erase the flash that it's writing the sketch to is to blow everything away with chip erase. In contrast, when programming via the bootloader, erase operations are done on a per-page basis.