Mistake with lock byte

Hi all,

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 :frowning:
Now I cannot detect the MCU anymore :frowning:
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.

Do you know a way ?

Best regards,
Denis

"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

This lock bits setting should not disable ISP. Check your wiring and clock source.

With avrdude -e issues a chip erase.

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.

Thank you for your replies.
But I think the 328p is broken I cannot connect to it.

I have another 328p and I used it and then I can detect it and burn the bootloader.

So I do not think the programer is involved there.
Really strange.